Skip to content

Commit

Permalink
fix: #990 Turn off ZipFile strict_timestamps
Browse files Browse the repository at this point in the history
Accommodate system dates before 1980-01-01.

This should have no effect for users with "normal" system clocks but
allows the package to save files in the unusual case the system clock is
set to a date prior to 1980.
  • Loading branch information
scanny committed Aug 3, 2024
1 parent 799b214 commit 284fc01
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
Release History
---------------

0.6.24-dev0
0.6.24-dev3
+++++++++++++++++++

- fix: #943 remove mention of a Px Length subtype
- fix: #972 next-slide-id fails in rare cases
- fix: #990 do not require strict timestamps for Zip

0.6.23 (2023-11-02)
+++++++++++++++++++
Expand Down
2 changes: 1 addition & 1 deletion src/pptx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
if TYPE_CHECKING:
from pptx.opc.package import Part

__version__ = "0.6.23"
__version__ = "0.6.24-dev3"

sys.modules["pptx.exceptions"] = exceptions
del sys
Expand Down
4 changes: 3 additions & 1 deletion src/pptx/opc/serialized.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ def write(self, pack_uri: PackURI, blob: bytes) -> None:
@lazyproperty
def _zipf(self) -> zipfile.ZipFile:
"""`ZipFile` instance open for writing."""
return zipfile.ZipFile(self._pkg_file, "w", compression=zipfile.ZIP_DEFLATED)
return zipfile.ZipFile(
self._pkg_file, "w", compression=zipfile.ZIP_DEFLATED, strict_timestamps=False
)


class _ContentTypesItem:
Expand Down
4 changes: 3 additions & 1 deletion tests/opc/test_serialized.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ def it_provides_access_to_the_open_zip_file_to_help(self, request: FixtureReques

zipf = pkg_writer._zipf

ZipFile_.assert_called_once_with("prs.pptx", "w", compression=zipfile.ZIP_DEFLATED)
ZipFile_.assert_called_once_with(
"prs.pptx", "w", compression=zipfile.ZIP_DEFLATED, strict_timestamps=False
)
assert zipf is ZipFile_.return_value

# fixtures ---------------------------------------------
Expand Down

0 comments on commit 284fc01

Please sign in to comment.