Title: ZipFile.extractall fails if zipfile.Path object is created based on the ZipFile object · Issue #101566 · python/cpython · GitHub
Open Graph Title: ZipFile.extractall fails if zipfile.Path object is created based on the ZipFile object · Issue #101566 · python/cpython
X Title: ZipFile.extractall fails if zipfile.Path object is created based on the ZipFile object · Issue #101566 · python/cpython
Description: Bug report The following code works fine with Python 3.8 and 3.9 but starts failing with Python 3.10. It seems that zipfile.Path creates an entry in the zipfile.ZipFile object that does not exist in the underlying file and therefore make...
Open Graph Description: Bug report The following code works fine with Python 3.8 and 3.9 but starts failing with Python 3.10. It seems that zipfile.Path creates an entry in the zipfile.ZipFile object that does not exist i...
X Description: Bug report The following code works fine with Python 3.8 and 3.9 but starts failing with Python 3.10. It seems that zipfile.Path creates an entry in the zipfile.ZipFile object that does not exist i...
Opengraph URL: https://github.com/python/cpython/issues/101566
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ZipFile.extractall fails if zipfile.Path object is created based on the ZipFile object","articleBody":"# Bug report\r\n\r\nThe following code works fine with Python 3.8 and 3.9 but starts failing with Python 3.10.\r\n\r\nIt seems that `zipfile.Path` creates an entry in the `zipfile.ZipFile` object that does not exist in the underlying file and therefore makes `zipfile.ZipFile.extractall` fail.\r\n\r\n```\r\nimport zipfile\r\nimport tempfile\r\n\r\npath = tempfile.mktemp()\r\n\r\nf = zipfile.ZipFile(path, \"w\")\r\nf.writestr(\"data/test.txt\", \"test1\")\r\nf.writestr(\"data/test2.txt\", \"test2\")\r\nf.close()\r\n\r\ndest = tempfile.mkdtemp()\r\n\r\np = zipfile.ZipFile(path)\r\nsrc_zipfile_path = zipfile.Path(p, \"data\")\r\np.extractall(dest)\r\n```\r\n\r\n# Your environment\r\n\r\nWorking version:\r\n\r\n```\r\n(python39) [moggi@mars cloudfluid]$ python --version\r\nPython 3.9.16\r\n(python39) [moggi@mars cloudfluid]$ python test.py\r\n(python39) [moggi@mars cloudfluid]$ \r\n```\r\n\r\nFailing versions:\r\n\r\n3.10.9:\r\n\r\n```\r\n(python_310_2) [moggi@mars cloudfluid]$ python --version\r\nPython 3.10.9\r\n(python_310_2) [moggi@mars cloudfluid]$ python test.py\r\nTraceback (most recent call last):\r\n File \"/home/moggi/devel/cloudfluid/test.py\", line 15, in \u003cmodule\u003e\r\n p.extractall(dest)\r\n File \"/home/moggi/devel/envs/python_310_2/lib/python3.10/zipfile.py\", line 1645, in extractall\r\n self._extract_member(zipinfo, path, pwd)\r\n File \"/home/moggi/devel/envs/python_310_2/lib/python3.10/zipfile.py\", line 1667, in _extract_member\r\n member = self.getinfo(member)\r\n File \"/home/moggi/devel/envs/python_310_2/lib/python3.10/zipfile.py\", line 1441, in getinfo\r\n raise KeyError(\r\nKeyError: \"There is no item named 'data/' in the archive\"\r\n```\r\n\r\nand 3.11.0\r\n\r\n```\r\n(python311) [moggi@mars cloudfluid]$ python --version\r\nPython 3.11.0\r\n(python311) [moggi@mars cloudfluid]$ python test.py\r\nTraceback (most recent call last):\r\n File \"/home/moggi/devel/cloudfluid/test.py\", line 15, in \u003cmodule\u003e\r\n p.extractall(dest)\r\n File \"/home/moggi/devel/envs/python311/lib/python3.11/zipfile.py\", line 1677, in extractall\r\n self._extract_member(zipinfo, path, pwd)\r\n File \"/home/moggi/devel/envs/python311/lib/python3.11/zipfile.py\", line 1699, in _extract_member\r\n member = self.getinfo(member)\r\n ^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/moggi/devel/envs/python311/lib/python3.11/zipfile.py\", line 1473, in getinfo\r\n raise KeyError(\r\nKeyError: \"There is no item named 'data/' in the archive\"\r\n\r\n```\r\n\r\nIf this is the expected new behavior I think the documentation for 3.10 should mention this breaking change and the `zipfile.Path` documentation might need an entry about this problem.\r\n\r\nThe `zipfile.Path` object is used in the original code to check if the \"data/\" directory exists in the zip file.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-102018\n* gh-102090\n* gh-102091\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/mmohrhard","@type":"Person","name":"mmohrhard"},"datePublished":"2023-02-04T18:09:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/101566/cpython/issues/101566"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2892a2bc-bcf4-346a-5bbf-9220d82bdeeb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AC48:2F5B11:34FF81:484DD8:6969DA0B |
| html-safe-nonce | e77906ef15d0f4da2e84f9d5f13b2d96acfb0e769c371dd5cf1163cd5c21ceb3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQzQ4OjJGNUIxMTozNEZGODE6NDg0REQ4OjY5NjlEQTBCIiwidmlzaXRvcl9pZCI6IjYxMjcyMDgwNjg1OTMzNDI5ODgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e6100949bc3f1f1e678c185462270f1617aa42cee587c966e4c9ad5267e69cc9 |
| hovercard-subject-tag | issue:1571058721 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/101566/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b3d1640d9768ecdd7289d988392a30bff60b06fb72a90f967ccde8161e8e90dc/python/cpython/issues/101566 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b3d1640d9768ecdd7289d988392a30bff60b06fb72a90f967ccde8161e8e90dc/python/cpython/issues/101566 |
| og:image:alt | Bug report The following code works fine with Python 3.8 and 3.9 but starts failing with Python 3.10. It seems that zipfile.Path creates an entry in the zipfile.ZipFile object that does not exist i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mmohrhard |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width