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

zipp.Path.glob does not find directories #121

Closed
theunkn0wn1 opened this issue Jun 7, 2024 · 2 comments · Fixed by #122
Closed

zipp.Path.glob does not find directories #121

theunkn0wn1 opened this issue Jun 7, 2024 · 2 comments · Fixed by #122
Assignees
Labels
bug Something isn't working

Comments

@theunkn0wn1
Copy link

using glob to find folders via zipp.Path.glob does not find the folder.
This issue also manifests in Cpython's zipfile.Path implementation, which appears to inherit from this codebase.

Environment

Ubuntu 22.04 Focal Fossa
Python3.10, python3.12.3 (obtained via pyenv)

 name         : zipp                                                        
 version      : 3.19.2                                                      
 description  : Backport of pathlib-compatible object wrapper for zip files 

Minimal example

First, build a zip archive with sufficient structure

mkdir -p /tmp/something
cd /tmp/something
mkdir -p top_level-4242/the_child_2213-039/
echo "i exist!!!" > top_level-4242/the_child_2213-039/flag.txt
zip demo.zip top_level-4242/the_child_2213-039/flag.txt   

Second, prove that with pathlib.Path.glob the folder is detectable:

from zipfile import ZipFile # to open the zip archive
from zipp import Path as ZipPath  # for the pathlib-compatible interface
from pathlib import Path  # for the pathlib interface
# path to target zip archive
target = Path("/tmp/something/zip_repo/demo.zip")
# path to source material on disk
as_pathlib = target.parent / "top_level-4242"
assert as_pathlib.exists() , "directory wasn't set up ahead of time!"
assert list(as_pathlib.glob("the_child*")), "pathlib: glob pattern miss."
# assertion passes

The assertion passes.

Third, demonstrate that zipp.Path does not behave as expected:

... # see above for setup
assert target.exists(), "sample zip archive not set up in advance!!!"
root = ZipPath(ZipFile(target)).joinpath("top_level-4242")
assert(list(root.glob("the_child*"))), "zipp: glob pattern miss."
# assertion error
@jaraco
Copy link
Owner

jaraco commented Aug 11, 2024

I just came here to report the same issue! Thanks for reporting it.

@jaraco jaraco self-assigned this Aug 11, 2024
@jaraco jaraco added the bug Something isn't working label Aug 11, 2024
jaraco added a commit that referenced this issue Aug 11, 2024
@jaraco jaraco closed this as completed in 5d89a1c Aug 11, 2024
@jaraco
Copy link
Owner

jaraco commented Aug 11, 2024

Fix released in v3.19.3.

jaraco added a commit to jaraco/cpython that referenced this issue Aug 11, 2024
Applies changes from zipp v3.19.2 and v3.19.3 (jaraco/zipp#121).
jaraco added a commit to jaraco/cpython that referenced this issue Aug 11, 2024
Applies changes from zipp v3.19.2 and v3.19.3 (jaraco/zipp#121).
jaraco added a commit to jaraco/cpython that referenced this issue Aug 11, 2024
Applies changes from zipp v3.19.2 and v3.19.3 (jaraco/zipp#121).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants