Author vstinner
Recipients vstinner
Date 2020-01-16.09:38:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1579167493.26.0.213163602183.issue39356@roundup.psfhosted.org>
In-reply-to
Content
Lib/zipfile.py contains the following code:

try:
    filename, flag_bits = zinfo._encodeFilenameFlags()
    centdir = struct.pack(structCentralDir,
                          stringCentralDir, create_version,
                          zinfo.create_system, extract_version, zinfo.reserved,
                          flag_bits, zinfo.compress_type, dostime, dosdate,
                          zinfo.CRC, compress_size, file_size,
                          len(filename), len(extra_data), len(zinfo.comment),
                          0, zinfo.internal_attr, zinfo.external_attr,
                          header_offset)
except DeprecationWarning:
    print((structCentralDir, stringCentralDir, create_version,
           zinfo.create_system, extract_version, zinfo.reserved,
           zinfo.flag_bits, zinfo.compress_type, dostime, dosdate,
           zinfo.CRC, compress_size, file_size,
           len(zinfo.filename), len(extra_data), len(zinfo.comment),
           0, zinfo.internal_attr, zinfo.external_attr,
           header_offset), file=sys.stderr)
    raise

It is not considered as good programmating method to put print() statement in production code: usually, it's only used for debugging :-)

The "except DeprecationWarning:" with its print has been added 12 years ago by:

commit bf02e3bb21b2d75cba4ce409a14ae64dbc2dd6d2
Author: Gregory P. Smith <greg@mad-scientist.com>
Date:   Wed Mar 19 03:14:41 2008 +0000

    Fix the struct module DeprecationWarnings that zipfile was triggering by
    removing all use of signed struct values.
    
    test_zipfile and test_zipfile64 pass.  no more warnings.

But I don't recall any complain about a DeprecationWarning on struct.pack() in zipfile.

I propose attached PR to remove it.
History
Date User Action Args
2020-01-16 09:38:13vstinnersetrecipients: + vstinner
2020-01-16 09:38:13vstinnersetmessageid: <1579167493.26.0.213163602183.issue39356@roundup.psfhosted.org>
2020-01-16 09:38:13vstinnerlinkissue39356 messages
2020-01-16 09:38:13vstinnercreate