Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue37772

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:zipfile.Path.iterdir() outputs sub directories many times or not at all
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.9, Python 3.8
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: jaracoNosy List: jaraco, joernheissler, shireenrao
Priority:normalKeywords:patch

Created on2019-08-06 06:57 byjoernheissler, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 15170mergedshireenrao,2019-08-07 22:49
PR 15461mergedmiss-islington,2019-08-24 15:30
Messages (7)
msg349101 -(view)Author: Jörn Heissler (joernheissler)*Date: 2019-08-06 06:57
Hello,#!/usr/bin/python3.8from zipfile import ZipFile, Pathimport iodef recurse_print(parent):    for child in parent.iterdir():        if child.is_file():            print(child, child.read_text())        if child.is_dir():            recurse_print(child)data = io.BytesIO()zf = ZipFile(data, "w")zf.writestr("a.txt", "content of a")zf.writestr("b/c.txt", "content of c")zf.writestr("b/d/e.txt", "content of e")zf.writestr("b/f.txt", "content of f")zf.filename = "abcde.zip"root = Path(zf)recurse_print(root)Expected result:abcde.zip/a.txt content of aabcde.zip/b/c.txt content of cabcde.zip/b/f.txt content of fabcde.zip/b/d/e.txt content of eActual result:abcde.zip/a.txt content of aabcde.zip/b/c.txt content of cabcde.zip/b/f.txt content of fabcde.zip/b/d/e.txt content of eabcde.zip/b/c.txt content of cabcde.zip/b/f.txt content of fabcde.zip/b/d/e.txt content of ePath._add_implied_dirs adds the sub directory "b/" twice: once for each direct child (i.e. "c.txt" and "f.txt")And similarly:data = io.BytesIO()zf = ZipFile(data, "w")zf.writestr("a.txt", "content of a")zf.writestr("b/d/e.txt", "content of e")zf.filename = "abcde.zip"root = Path(zf)recurse_print(root)Expected result:abcde.zip/a.txt content of aabcde.zip/b/d/e.txt content of eActual result:abcde.zip/a.txt content of aHere, Path._add_implied_dirs doesn't add "b/" at all, because there are no direct childs of "b".
msg349150 -(view)Author: Srinivas Nyayapati (shireenrao)*Date: 2019-08-07 04:25
I have attempted a fix to Path._add_implied_dirs and have the changes in my github branchhttps://github.com/shireenrao/cpython/tree/zipfile. Is it ok if I submitted a PR on this? I have run test_zipfile.py and the test case provided by Jörn Heissler successfully.
msg349201 -(view)Author: Jason R. Coombs (jaraco)*(Python committer)Date: 2019-08-07 21:12
Please do.
msg349205 -(view)Author: Srinivas Nyayapati (shireenrao)*Date: 2019-08-08 00:08
I just submitted my PR.
msg350374 -(view)Author: Jason R. Coombs (jaraco)*(Python committer)Date: 2019-08-24 15:26
New changeseta4e2991bdc993b60b6457c8a38d6e4a1fc845781 by Jason R. Coombs (shireenrao) in branch 'master':bpo-37772: fix zipfile.Path.iterdir() outputs (GH-15170)https://github.com/python/cpython/commit/a4e2991bdc993b60b6457c8a38d6e4a1fc845781
msg350375 -(view)Author: Jason R. Coombs (jaraco)*(Python committer)Date: 2019-08-24 16:03
New changesetc410f381bf66c48d84812e19e3ba7c2878511a3e by Jason R. Coombs (Miss Islington (bot)) in branch '3.8':bpo-37772: fix zipfile.Path.iterdir() outputs (GH-15170) (#15461)https://github.com/python/cpython/commit/c410f381bf66c48d84812e19e3ba7c2878511a3e
msg350376 -(view)Author: Jason R. Coombs (jaraco)*(Python committer)Date: 2019-08-24 16:28
Thanks very much shireenrao for the PR, which is now merged with Python 3.8+. I've additionally backported the fix to zipp in 0.6.0.
History
DateUserActionArgs
2022-04-11 14:59:18adminsetgithub: 81953
2019-08-24 16:28:26jaracosetstatus: open -> closed
versions: + Python 3.8
messages: +msg350376

resolution: fixed
stage: patch review -> resolved
2019-08-24 16:03:55jaracosetmessages: +msg350375
2019-08-24 15:30:25miss-islingtonsetpull_requests: +pull_request15155
2019-08-24 15:26:44jaracosetmessages: +msg350374
2019-08-08 00:08:16shireenraosetmessages: +msg349205
2019-08-07 22:49:26shireenraosetkeywords: +patch
stage: patch review
pull_requests: +pull_request14902
2019-08-07 21:13:53jaracosetassignee:jaraco
2019-08-07 21:12:45jaracosetmessages: +msg349201
2019-08-07 04:25:14shireenraosetnosy: +shireenrao
messages: +msg349150
2019-08-06 21:03:21brett.cannonsetnosy: +jaraco
2019-08-06 06:57:30joernheisslercreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp