-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Comments
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. |
Following on from #102622, if we want to remove these old aliases, we should follow PEP 387 and deprecate by raising Searching the top 5,000 packages for 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
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 |
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. |
I agree it’s not worth the disruption. |
Fine by me. The Shall we document the 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 |
On the other hand, bpo-7351 added And |
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 |
Sounds reasonable, let's close this then. To summarise:
|
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: