Skip to content

Commit 24cb932

Browse files
committed
Simplify and update comments for simplified check
1 parent e39237d commit 24cb932

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

Doc/library/zipfile.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ ZipFile objects
286286
metadata in the zipfile's directory and file headers.
287287

288288
.. versionchanged:: next
289-
Deleting a :class:`zipfile.ZipFile` which contains unwritten data before
290-
it is closed now emits a :exc:`ResourceWarning`. Use as a
291-
:term:`context manager` or call :meth:`~zipfile.ZipFile.close` explicitly.
289+
Deleting a writable, open :class:`zipfile.ZipFile` now emits a
290+
:exc:`ResourceWarning`. Use as a :term:`context manager` or call
291+
:meth:`~zipfile.ZipFile.close` explicitly.
292292

293293
.. method:: ZipFile.close()
294294

Lib/zipfile/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,9 +2617,8 @@ def mkdir(self, zinfo_or_directory_name, mode=511):
26172617

26182618
def __del__(self):
26192619
"""Call the "close()" method in case the user forgot."""
2620-
# gh-81954: Warn if ZipFile is implicitly closed with unwritten end
2621-
# records. GC cleanup order is non-deterministic and can result in data
2622-
# loss.
2620+
# gh-81954: Warn if writable ZipFile is implicitly closed.
2621+
# GC cleanup order is non-deterministic and can result in data loss.
26232622
if self.fp is not None and self.mode in ('w', 'x', 'a'):
26242623
warnings.warn(f"unclosed ZipFile {self!r}",
26252624
ResourceWarning, source=self, stacklevel=2)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Deleting a :class:`zipfile.ZipFile` which contains unwritten data before it
2-
is closed now emits a :exc:`ResourceWarning`. Use as a :term:`context manager`
1+
Deleting a writable, open :class:`zipfile.ZipFile` now emits a
2+
:exc:`ResourceWarning`. Use as a :term:`context manager`
33
or call :meth:`~zipfile.ZipFile.close` explicitly.

0 commit comments

Comments
 (0)