Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the error and the zipfile.ZipFile.BadZipfile aliases #86437

Closed
PedanticHacker mannequin opened this issue Nov 5, 2020 · 8 comments
Closed

Remove the error and the zipfile.ZipFile.BadZipfile aliases #86437

PedanticHacker mannequin opened this issue Nov 5, 2020 · 8 comments
Labels
3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@PedanticHacker
Copy link
Mannequin

PedanticHacker mannequin commented Nov 5, 2020

BPO 42271
Nosy @Yhg1s, @serhiy-storchaka, @PedanticHacker
PRs
  • issue42271: Remove the 'error' and the 'BadZipfile' aliases #23171
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2020-11-05.19:21:47.742>
    labels = ['type-feature', 'library', '3.10']
    title = 'Remove the error and the zipfile.ZipFile.BadZipfile aliases'
    updated_at = <Date 2020-11-06.10:04:14.271>
    user = 'https://github.com/PedanticHacker'

    bugs.python.org fields:

    activity = <Date 2020-11-06.10:04:14.271>
    actor = 'xtreak'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2020-11-05.19:21:47.742>
    creator = 'PedanticHacker'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42271
    keywords = []
    message_count = 1.0
    messages = ['380428']
    nosy_count = 4.0
    nosy_names = ['twouters', 'alanmcintyre', 'serhiy.storchaka', 'PedanticHacker']
    pr_nums = ['23171']
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue42271'
    versions = ['Python 3.10']

    @PedanticHacker
    Copy link
    Mannequin Author

    PedanticHacker mannequin commented Nov 5, 2020

    Remove the long-forgotten aliases 'error' and 'BadZipfile' in 'zipfile.ZipFile' class which are just pre-3.2 compatibility names. Python 3.10 should finally remove these aliases.

    @PedanticHacker PedanticHacker mannequin added 3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Nov 5, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @hugovk
    Copy link
    Member

    hugovk commented Mar 12, 2023

    Following on from #102622, if we want to remove these old aliases, we should follow PEP 387 and deprecate by raising DeprecationWarning in 3.12, and can then remove in 3.14.

    Searching the top 5,000 packages for BadZipfile, there's still quite some use (~35 projects):

    Details
    $ python3 ~/github/misc/cpython/search_pypi_top.py . "BadZipfile" -q
    ./pex-2.1.122.tar.gz: pex-2.1.122/pex/vendor/_vendored/pip/pip/_internal/network/lazy_wheel.py: from zipfile import BadZipfile, ZipFile
    ./pex-2.1.122.tar.gz: pex-2.1.122/pex/vendor/_vendored/pip/pip/_internal/network/lazy_wheel.py: except BadZipfile:
    ./pex-2.1.122.tar.gz: pex-2.1.122/pex/vendor/_vendored/pip/pip/_internal/utils/wheel.py: from zipfile import BadZipfile as BadZipFile
    ./hexbytes-0.3.0.tar.gz: hexbytes-0.3.0/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/@python2/zipfile.pyi: class BadZipfile(Exception): ...
    ./hexbytes-0.3.0.tar.gz: hexbytes-0.3.0/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/@python2/zipfile.pyi: error = BadZipfile
    ./hexbytes-0.3.0.tar.gz: hexbytes-0.3.0/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: "BadZipfile",
    ./hexbytes-0.3.0.tar.gz: hexbytes-0.3.0/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: BadZipfile = BadZipFile
    ./hexbytes-0.3.0.tar.gz: hexbytes-0.3.0/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: error = BadZipfile
    ./hexbytes-0.3.0.tar.gz: hexbytes-0.3.0/.tox/py39-lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/@python2/zipfile.pyi: class BadZipfile(Exception): ...
    ./hexbytes-0.3.0.tar.gz: hexbytes-0.3.0/.tox/py39-lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/@python2/zipfile.pyi: error = BadZipfile
    ./hexbytes-0.3.0.tar.gz: hexbytes-0.3.0/.tox/py39-lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: "BadZipfile",
    ./hexbytes-0.3.0.tar.gz: hexbytes-0.3.0/.tox/py39-lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: BadZipfile = BadZipFile
    ./hexbytes-0.3.0.tar.gz: hexbytes-0.3.0/.tox/py39-lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: error = BadZipfile
    ./jedi-0.18.2.tar.gz: jedi-0.18.2/jedi/third_party/typeshed/stdlib/2and3/zipfile.pyi: BadZipfile = BadZipFile
    ./jedi-0.18.2.tar.gz: jedi-0.18.2/jedi/third_party/typeshed/stdlib/2and3/zipfile.pyi: class BadZipfile(Exception): ...
    ./jedi-0.18.2.tar.gz: jedi-0.18.2/jedi/third_party/typeshed/stdlib/2and3/zipfile.pyi: error = BadZipfile
    ./devpi-common-3.7.2.tar.gz: devpi-common-3.7.2/devpi_common/archive.py: except zipfile.BadZipfile:
    ./pyre-check-0.9.18.tar.gz: pyre-check-0.9.18/typeshed/stdlib/zipfile.pyi: "BadZipfile",
    ./pyre-check-0.9.18.tar.gz: pyre-check-0.9.18/typeshed/stdlib/zipfile.pyi: BadZipfile = BadZipFile
    ./pyre-check-0.9.18.tar.gz: pyre-check-0.9.18/typeshed/stdlib/zipfile.pyi: error = BadZipfile
    ./ansible-core-2.14.2.tar.gz: ansible-core-2.14.2/lib/ansible/modules/unarchive.py: from zipfile import ZipFile, BadZipfile
    ./ansible-core-2.14.2.tar.gz: ansible-core-2.14.2/lib/ansible/modules/unarchive.py: except BadZipfile as e:
    ./ansible-core-2.14.2.tar.gz: ansible-core-2.14.2/lib/ansible/modules/unarchive.py: except BadZipfile as e:
    ./zipfile36-0.1.3.tar.gz: zipfile36-0.1.3/zipfile36.py: __all__ = ["BadZipFile", "BadZipfile", "error",
    ./zipfile36-0.1.3.tar.gz: zipfile36-0.1.3/zipfile36.py: error = BadZipfile = BadZipFile      # Pre-3.2 compatibility names
    ./pip-23.0.1.tar.gz: pip-23.0.1/src/pip/_internal/network/lazy_wheel.py: from zipfile import BadZipfile, ZipFile
    ./pip-23.0.1.tar.gz: pip-23.0.1/src/pip/_internal/network/lazy_wheel.py: except BadZipfile:
    ./xmltodict-0.13.0.tar.gz: xmltodict-0.13.0/ez_setup.py: except zipfile.BadZipfile as err:
    ./xlsx2csv-0.8.1.tar.gz: xlsx2csv-0.8.1/xlsx2csv.py: except (zipfile.BadZipfile, IOError):
    ./xlsx2csv-0.8.1.tar.gz: xlsx2csv-0.8.1/xlsx2csv.py: except zipfile.BadZipfile:
    ./pylzma-0.5.0.tar.gz: pylzma-0.5.0/ez_setup.py: except zipfile.BadZipfile as err:
    ./pyzipper-0.3.6.tar.gz: pyzipper-0.3.6/pyzipper/zipfile.py: __all__ = ["BadZipFile", "BadZipfile", "error",
    ./pyzipper-0.3.6.tar.gz: pyzipper-0.3.6/pyzipper/zipfile.py: error = BadZipfile = BadZipFile      # Pre-3.2 compatibility names
    ./eth-hash-0.5.1.tar.gz: eth-hash-0.5.1/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/@python2/zipfile.pyi: class BadZipfile(Exception): ...
    ./eth-hash-0.5.1.tar.gz: eth-hash-0.5.1/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/@python2/zipfile.pyi: error = BadZipfile
    ./eth-hash-0.5.1.tar.gz: eth-hash-0.5.1/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: "BadZipfile",
    ./eth-hash-0.5.1.tar.gz: eth-hash-0.5.1/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: "BadZipfile",
    ./eth-hash-0.5.1.tar.gz: eth-hash-0.5.1/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: BadZipfile = BadZipFile
    ./eth-hash-0.5.1.tar.gz: eth-hash-0.5.1/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: error = BadZipfile
    ./pyexcel-io-0.6.6.tar.gz: pyexcel-io-0.6.6/pyexcel_io/readers/csvz.py: except zipfile.BadZipfile:
    ./pyexcel-io-0.6.6.tar.gz: pyexcel-io-0.6.6/tests/test_io.py: from zipfile import BadZipfile
    ./pyexcel-io-0.6.6.tar.gz: pyexcel-io-0.6.6/tests/test_io.py: @raises(BadZipfile)
    ./pandas-1.5.3.tar.gz: pandas-1.5.3/pandas/tests/io/parser/test_compression.py: with pytest.raises(zipfile.BadZipfile, match="File is not a zip file"):
    ./CT3-3.3.1.tar.gz: CT3-3.3.1/.tox/py37/lib/python3.7/site-packages/pip/_internal/network/lazy_wheel.py: from zipfile import BadZipfile, ZipFile
    ./CT3-3.3.1.tar.gz: CT3-3.3.1/.tox/py37/lib/python3.7/site-packages/pip/_internal/network/lazy_wheel.py: except BadZipfile:
    ./CT3-3.3.1.tar.gz: CT3-3.3.1/.tox/py37-flake8/lib/python3.7/site-packages/pip/_internal/network/lazy_wheel.py: from zipfile import BadZipfile, ZipFile
    ./CT3-3.3.1.tar.gz: CT3-3.3.1/.tox/py37-flake8/lib/python3.7/site-packages/pip/_internal/network/lazy_wheel.py: except BadZipfile:
    ./ansible-7.2.0.tar.gz: ansible-7.2.0/ansible_collections/community/general/plugins/modules/archive.py: except zipfile.BadZipfile:
    ./datapackage-1.15.2.tar.gz: datapackage-1.15.2/datapackage/package.py: except (IOError, zipfile.BadZipfile, zipfile.LargeZipFile) as exception:
    ./datapackage-1.15.2.tar.gz: datapackage-1.15.2/datapackage/package.py: zipfile.BadZipfile):
    ./eth-utils-2.1.0.tar.gz: eth-utils-2.1.0/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: BadZipfile = BadZipFile
    ./eth-utils-2.1.0.tar.gz: eth-utils-2.1.0/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: class BadZipfile(Exception): ...
    ./eth-utils-2.1.0.tar.gz: eth-utils-2.1.0/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/zipfile.pyi: error = BadZipfile
    ./cassandra-driver-3.25.0.tar.gz: cassandra-driver-3.25.0/cassandra/datastax/cloud/__init__.py: from zipfile import BadZipfile as BadZipFile
    ./scylla-driver-3.25.11.tar.gz: scylla-driver-3.25.11/cassandra/datastax/cloud/__init__.py: from zipfile import BadZipfile as BadZipFile
    ./pyinstaller-5.8.0.tar.gz: pyinstaller-5.8.0/PyInstaller/depend/bindepend.py: except zipfile.BadZipfile as e:
    ./eth-account-0.8.0.tar.gz: eth-account-0.8.0/.tox/lint/lib/python3.10/site-packages/mypy/typeshed/stdlib/zipfile.pyi: BadZipfile = BadZipFile
    ./eth-account-0.8.0.tar.gz: eth-account-0.8.0/.tox/lint/lib/python3.10/site-packages/mypy/typeshed/stdlib/zipfile.pyi: class BadZipfile(Exception): ...
    ./eth-account-0.8.0.tar.gz: eth-account-0.8.0/.tox/lint/lib/python3.10/site-packages/mypy/typeshed/stdlib/zipfile.pyi: error = BadZipfile
    ./eth-account-0.8.0.tar.gz: eth-account-0.8.0/.tox/py310-lint/lib/python3.10/site-packages/mypy/typeshed/stdlib/zipfile.pyi: BadZipfile = BadZipFile
    ./eth-account-0.8.0.tar.gz: eth-account-0.8.0/.tox/py310-lint/lib/python3.10/site-packages/mypy/typeshed/stdlib/zipfile.pyi: class BadZipfile(Exception): ...
    ./eth-account-0.8.0.tar.gz: eth-account-0.8.0/.tox/py310-lint/lib/python3.10/site-packages/mypy/typeshed/stdlib/zipfile.pyi: error = BadZipfile
    ./mypy-1.0.1.tar.gz: mypy-1.0.1/mypy/typeshed/stdlib/zipfile.pyi: "BadZipfile",
    ./mypy-1.0.1.tar.gz: mypy-1.0.1/mypy/typeshed/stdlib/zipfile.pyi: BadZipfile = BadZipFile
    ./mypy-1.0.1.tar.gz: mypy-1.0.1/mypy/typeshed/stdlib/zipfile.pyi: error = BadZipfile
    ./awscli-1.27.74.tar.gz: awscli-1.27.74/awscli/customizations/awslambda.py: except zipfile.BadZipfile:
    ./pipenv-2023.2.18.tar.gz: pipenv-2023.2.18/pipenv/patched/pip/_internal/network/lazy_wheel.py: from zipfile import BadZipfile, ZipFile
    ./pipenv-2023.2.18.tar.gz: pipenv-2023.2.18/pipenv/patched/pip/_internal/network/lazy_wheel.py: except BadZipfile:
    ./eth-rlp-0.3.0.tar.gz: eth-rlp-0.3.0/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/2and3/zipfile.pyi: BadZipfile = BadZipFile
    ./eth-rlp-0.3.0.tar.gz: eth-rlp-0.3.0/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/2and3/zipfile.pyi: class BadZipfile(Exception): ...
    ./eth-rlp-0.3.0.tar.gz: eth-rlp-0.3.0/.tox/lint/lib/python3.9/site-packages/mypy/typeshed/stdlib/2and3/zipfile.pyi: error = BadZipfile
    ./pyLDAvis-3.4.0.tar.gz: pyLDAvis-3.4.0/pyLDAvis/lib/python3.11/site-packages/pip/_internal/network/lazy_wheel.py: from zipfile import BadZipfile, ZipFile
    ./pyLDAvis-3.4.0.tar.gz: pyLDAvis-3.4.0/pyLDAvis/lib/python3.11/site-packages/pip/_internal/network/lazy_wheel.py: except BadZipfile:
    ./eth-rlp-0.3.0.tar.gz: eth-rlp-0.3.0/venv-erlp/lib/python3.9/site-packages/jedi/third_party/typeshed/stdlib/2and3/zipfile.pyi: BadZipfile = BadZipFile
    ./eth-rlp-0.3.0.tar.gz: eth-rlp-0.3.0/venv-erlp/lib/python3.9/site-packages/jedi/third_party/typeshed/stdlib/2and3/zipfile.pyi: class BadZipfile(Exception): ...
    ./eth-rlp-0.3.0.tar.gz: eth-rlp-0.3.0/venv-erlp/lib/python3.9/site-packages/jedi/third_party/typeshed/stdlib/2and3/zipfile.pyi: error = BadZipfile
    ./zipfile38-0.0.3.tar.gz: zipfile38-0.0.3/zipfile38.py: __all__ = ["BadZipFile", "BadZipfile", "error",
    ./zipfile38-0.0.3.tar.gz: zipfile38-0.0.3/zipfile38.py: error = BadZipfile = BadZipFile      # Pre-3.2 compatibility names
    ./eth-rlp-0.3.0.tar.gz: eth-rlp-0.3.0/venv-erlp/lib/python3.9/site-packages/mypy/typeshed/stdlib/2and3/zipfile.pyi: BadZipfile = BadZipFile
    ./eth-rlp-0.3.0.tar.gz: eth-rlp-0.3.0/venv-erlp/lib/python3.9/site-packages/mypy/typeshed/stdlib/2and3/zipfile.pyi: class BadZipfile(Exception): ...
    ./eth-rlp-0.3.0.tar.gz: eth-rlp-0.3.0/venv-erlp/lib/python3.9/site-packages/mypy/typeshed/stdlib/2and3/zipfile.pyi: error = BadZipfile
    ./googledrivedownloader-0.4.tar.gz: googledrivedownloader-0.4/google_drive_downloader/google_drive_downloader.py: except zipfile.BadZipfile:
    ./Scrapy-2.8.0.tar.gz: Scrapy-2.8.0/scrapy/downloadermiddlewares/decompression.py: except zipfile.BadZipfile:
    ./eth_abi-3.0.1.tar.gz: eth_abi-3.0.1/.tox/lint/lib/python3.10/site-packages/mypy/typeshed/stdlib/zipfile.pyi: BadZipfile = BadZipFile
    ./eth_abi-3.0.1.tar.gz: eth_abi-3.0.1/.tox/lint/lib/python3.10/site-packages/mypy/typeshed/stdlib/zipfile.pyi: class BadZipfile(Exception): ...
    ./eth_abi-3.0.1.tar.gz: eth_abi-3.0.1/.tox/lint/lib/python3.10/site-packages/mypy/typeshed/stdlib/zipfile.pyi: error = BadZipfile
    ./Twisted-22.10.0.tar.gz: Twisted-22.10.0/src/twisted/python/test/test_zipstream.py: A zipfile entry with the wrong magic number should raise BadZipfile for
    ./Twisted-22.10.0.tar.gz: Twisted-22.10.0/src/twisted/python/test/test_zipstream.py: self.assertRaises(zipfile.BadZipfile, czf.readfile, "0")
    ./Twisted-22.10.0.tar.gz: Twisted-22.10.0/src/twisted/python/test/test_zipstream.py: directory should raise BadZipfile.
    ./Twisted-22.10.0.tar.gz: Twisted-22.10.0/src/twisted/python/test/test_zipstream.py: self.assertRaises(zipfile.BadZipfile, czf.readfile, "0")
    ./Twisted-22.10.0.tar.gz: Twisted-22.10.0/src/twisted/python/test/test_zipstream.py: raise BadZipfile.
    ./Twisted-22.10.0.tar.gz: Twisted-22.10.0/src/twisted/python/test/test_zipstream.py: self.assertRaises(zipfile.BadZipfile, czf.readfile, "0")
    ./Twisted-22.10.0.tar.gz: Twisted-22.10.0/src/twisted/python/zipstream.py: raise zipfile.BadZipfile("Bad magic number for file header")
    ./Twisted-22.10.0.tar.gz: Twisted-22.10.0/src/twisted/python/zipstream.py: raise zipfile.BadZipfile(
    ./Twisted-22.10.0.tar.gz: Twisted-22.10.0/src/twisted/python/zipstream.py: raise zipfile.BadZipfile(
    ./pytype-2023.2.17.tar.gz: pytype-2023.2.17/pytype/typeshed/stdlib/zipfile.pyi: "BadZipfile",
    ./pytype-2023.2.17.tar.gz: pytype-2023.2.17/pytype/typeshed/stdlib/zipfile.pyi: BadZipfile = BadZipFile
    ./pytype-2023.2.17.tar.gz: pytype-2023.2.17/pytype/typeshed/stdlib/zipfile.pyi: error = BadZipfile
    ./XlsxWriter-3.0.8.tar.gz: XlsxWriter-3.0.8/examples/vba_extract.py: from zipfile import BadZipfile
    ./XlsxWriter-3.0.8.tar.gz: XlsxWriter-3.0.8/examples/vba_extract.py: except BadZipfile as e:
    
    Time: 0:00:16.567254
    Found 100 matching lines in 35 projects

    error is a bit harder to search for, but also has some use (~5 projects):

    Details
    $ python3 ~/github/misc/cpython/search_pypi_top.py . "zipfile.*error" -q
    ./zipfile-deflate64-0.2.0.tar.gz: zipfile-deflate64-0.2.0/zipfile_deflate64/_zipfile.py: # This is already defined in zipfile.compressor_names, for error-handling purposes
    ./pyinstaller-5.8.0.tar.gz: pyinstaller-5.8.0/PyInstaller/lib/modulegraph/zipio.py: except _zipfile.error:
    ./pyinstaller-5.8.0.tar.gz: pyinstaller-5.8.0/PyInstaller/lib/modulegraph/zipio.py: except (_zipfile.error, KeyError):
    ./pyinstaller-5.8.0.tar.gz: pyinstaller-5.8.0/PyInstaller/lib/modulegraph/zipio.py: except _zipfile.error:
    ./pyinstaller-5.8.0.tar.gz: pyinstaller-5.8.0/PyInstaller/lib/modulegraph/zipio.py: except _zipfile.error:
    ./pyinstaller-5.8.0.tar.gz: pyinstaller-5.8.0/PyInstaller/lib/modulegraph/zipio.py: except (_zipfile.error, IOError):
    ./pyinstaller-5.8.0.tar.gz: pyinstaller-5.8.0/PyInstaller/lib/modulegraph/zipio.py: except (KeyError, _zipfile.error):
    ./pyinstaller-5.8.0.tar.gz: pyinstaller-5.8.0/PyInstaller/lib/modulegraph/zipio.py: except (_zipfile.error, IOError):
    ./pyinstaller-5.8.0.tar.gz: pyinstaller-5.8.0/PyInstaller/lib/modulegraph/zipio.py: except _zipfile.error:
    ./pyinstaller-5.8.0.tar.gz: pyinstaller-5.8.0/PyInstaller/lib/modulegraph/zipio.py: except _zipfile.error:
    ./nltk-3.8.1.zip: nltk-3.8.1/nltk/downloader.py: except zipfile.error as e:
    ./pytype-2023.2.17.tar.gz: pytype-2023.2.17/pytype/pytype_source_utils.py: filenames = loader.get_zipfile().namelist()  # pytype: disable=attribute-error
    ./temporalio-1.0.0.tar.gz: <snip>
    
    Time: 0:00:16.972358
    Found 13 matching lines in 5 projects

    @JelleZijlstra
    Copy link
    Member

    I'm not sure it's worth removing these aliases. The upside of removing it is that we get to remove one line from our code and satisfy some people's cleanliness instinct. The downside is that lots and lots of code that uses these aliases and works fine needs to change.

    @ericvsmith
    Copy link
    Member

    I agree it’s not worth the disruption.

    @hugovk
    Copy link
    Member

    hugovk commented Mar 13, 2023

    Fine by me.


    The BadZipfile alias is documented: https://docs.python.org/3/library/zipfile.html#zipfile.BadZipfile

    Shall we document the error alias, as deprecated since 3.2 or 3.12?

    diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
    index 0195abc3a9..788bc1317f 100644
    --- a/Doc/library/zipfile.rst
    +++ b/Doc/library/zipfile.rst
    @@ -39,6 +39,13 @@ The module defines the following items:
        .. deprecated:: 3.2
     
     
    +.. exception:: error
    +
    +   Alias of :exc:`BadZipFile`, for compatibility with older Python versions.
    +
    +   .. deprecated:: 3.2
    +
    +
     .. exception:: LargeZipFile
     
        The error raised when a ZIP file would require ZIP64 functionality but that has

    @hugovk
    Copy link
    Member

    hugovk commented Mar 13, 2023

    On the other hand, bpo-7351 added BadZipFile and deprecated only BadZipfile: 4d54088.

    And error has been there since day zero: 32abe6f#diff-b5cf7374d79aae191c1e38d0959527e0bbb7a95e0df5b125a8b1056cc2c54851R15

    @JelleZijlstra
    Copy link
    Member

    I don't think we need to document it, we'd leave it around only for compatibility with older code. We should definitely steer people to use only BadZipFile if they're writing code today.

    @hugovk
    Copy link
    Member

    hugovk commented Mar 16, 2023

    Sounds reasonable, let's close this then.

    To summarise:

    • BadZipfile is documented as deprecated since 3.2 in docs, people should use BadZipFile in new code
    • error was never deprecated
    • It's not worth removing the BadZipfile and error aliases, it's only two lines of code to keep them

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    Status: Done
    Development

    No branches or pull requests

    3 participants