-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
BytesWarning in zipimport paths on sys.path #91182
Comments
importing from a bytes zipimport path on sys.path results in a BytesWarning: Comparison between bytes and string running the reproducer with see also https://bugs.python.org/issue47025 |
This warning can be fixed by changing the following line: cpython/Lib/importlib/_bootstrap_external.py Line 1419 in 9d1c4d6
to: if not path and str(path) == '': and running Alternatively the change can be: if not path and isinstance(path, (str,bytes)): I'm not sure which is preferable or if some other fix would be better (I don't know much about importlib). === Adding a full traceback with -bb argument: Traceback (most recent call last):
File "/Users/ak/temp2/zipfile_demo.py", line 29, in <module>
sys.exit(main())
^^^^^^
File "/Users/ak/opensource/cpython4/Lib/contextlib.py", line 155, in __exit__
self.gen.throw(typ, value, traceback)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ak/temp2/zipfile_demo.py", line 12, in _tmp_path
yield pathlib.Path(tmp_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ak/temp2/zipfile_demo.py", line 24, in main
import module
^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1080, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1493, in find_spec
File "<frozen importlib._bootstrap_external>", line 1462, in _get_spec
File "<frozen importlib._bootstrap_external>", line 1418, in _path_importer_cache
BytesWarning: Comparison between bytes and string |
bpo-47025 is a bigger discussion about bytes paths that probably needs to be resolved first before worrying about zipimport. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: