8000 AttributeError: 'zipimporter' object has no attribute '_files' · Issue #121552 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

AttributeError: 'zipimporter' object has no attribute '_files' #121552

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

Closed
catchyzheng opened this issue Jul 9, 2024 · 4 comments
Closed

AttributeError: 'zipimporter' object has no attribute '_files' #121552

catchyzheng opened this issue Jul 9, 2024 · 4 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@catchyzheng
Copy link
catchyzheng commented Jul 9, 2024

Bug report

Bug description:

Hello,

I encountered this error when running code on python 3.13.

for file_path in importer._files:
E       AttributeError: 'zipimporter' object has no attribute '_files'

I suspect sth is changed in Lib/zipimport.py, but i am not sure.

Hope someone can provide some guidance, thank you!

CPython versions tested on:

3.13

Operating systems tested on:

Linux, macOS

@catchyzheng catchyzheng added the type-bug An unexpected behavior, bug, or error label Jul 9, 2024
@Eclips4
Copy link
Member
Eclips4 commented Jul 9, 2024

Hello! Yes, the zipimporter._files attribute has been removed in version 3.13: #103208. Since this attribute is private and not documented anywhere else, it was removed without any deprecation process.
So, you need to update your code :)
Actually, maybe it would make sense to mention this removal in the changelog, but I'm not sure how many users are using it, since it's a private, undocumented attribute.

@ZeroIntensity
Copy link
Member

FWIW, the new way to do it is through the new _get_files() method instead of _files. Note that this is a private API too, though.

@catchyzheng
Copy link
Author

Thank you! Yes the _get_files() works.

@Eclips4 Eclips4 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2024
@graingert
Copy link
Contributor

@catchyzheng I'd highly recommend using a public API eg importlib.resources.files(...).iterdir() to walk the tree of files instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants
0