-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
str(zipfile.Path()) not working when root attribute is io.BytesIO #100609
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
Comments
This is mentioned in the Lines 216 to 226 in 79c10b7
This feature feels fine within the third-party zipp package -- where We may have an opportunity to revise this when we introduce a fully pathlib-compatible implementation of |
I'm not sure I understand the distinction.
And it does currently through I don't like the implementation of But you're right, it's not great to not have a good |
Sorry for not being clear. It would suffice to make the original |
In jaraco/zipp#107, I determined that it's not going to be straightforward to support these attributes, and the best recommendation is for users to provide a filename on the ZipFile object. At this point, I'm thinking the best option might be to document these limitations and recommendations. |
In #130120 and the linked PR, @yngvem is exploring this issue. As you can see above, I'd previously concluded:
And
@yngvem - what do you think of the recommendation for the caller to set the zipfile What do you think about the following approach:
|
@jaraco, I think that approach seems very reasonable! Though, maybe it would be nice if the TypeError is raised explicitly in I would be happy to provide all those changes :) |
Are there other parts of the stdlib where |
@barneygale, I also think it seems weird for I updated #130381 which makes |
I like the idea of using
|
A similar-ish case in pathlib comes to mind - |
I've logged this upstream issue: jaraco/zipp#134 |
And an upstream PR: jaraco/zipp#135 |
Using
zipfile.Path
with a ZIP-file "in memory" asio.BytesIO
instance. In that case attributes like.filename()
or.__str__()
do not work because they try to instanciate apathlib.Path()
with aio.BytesIO
object.I can confirm this with Python 3.11 (run in Docker), Python 3.10.2 (Windows) and Python 3.9.2 (Debian stable). See output below for detailed version infos.
Code to reproduce
Output: Python 3.11 on Linux/Docker
Output: Python 3.10 on Windows
Output: Python 3.9.2 on Debian stable (11)
The text was updated successfully, but these errors were encountered: