diff --git a/Lib/zipfile/__init__.py b/Lib/zipfile/__init__.py index 6c353b4ff850626..764bb9b1e9246f6 100644 --- a/Lib/zipfile/__init__.py +++ b/Lib/zipfile/__init__.py @@ -620,7 +620,6 @@ def _decodeExtra(self, filename_crc): if up_unicode_name: self.filename = _sanitize_filename(up_unicode_name) else: - import warnings warnings.warn("Empty unicode path extra field (0x7075)", stacklevel=2) except struct.error as e: raise BadZipFile("Corrupt unicode path extra field (0x7075)") from e @@ -2153,7 +2152,6 @@ def comment(self, comment): raise TypeError("comment: expected bytes, got %s" % type(comment).__name__) # check for valid comment length if len(comment) > ZIP_MAX_COMMENT: - import warnings warnings.warn('Archive comment is too long; truncating to %d bytes' % ZIP_MAX_COMMENT, stacklevel=2) comment = comment[:ZIP_MAX_COMMENT] @@ -2244,7 +2242,6 @@ def open(self, name, mode="r", pwd=None, *, force_zip64=False): if (zinfo._end_offset is not None and zef_file.tell() + zinfo.compress_size > zinfo._end_offset): if zinfo._end_offset == zinfo.header_offset: - import warnings warnings.warn( f"Overlapped entries: {zinfo.orig_filename!r} " f"(possible zip bomb)", @@ -2494,7 +2491,6 @@ def _extract_member(self, member, targetpath, pwd): def _writecheck(self, zinfo): """Check for errors before writing a file to the archive.""" if zinfo.filename in self.NameToInfo: - import warnings warnings.warn('Duplicate name: %r' % zinfo.filename, stacklevel=3) if self.mode not in ('w', 'x', 'a'): raise ValueError("write() requires mode 'w', 'x', or 'a'")