[issue47026] BytesWarning in zipimport paths on sys.path

2022-03-21 Thread Brett Cannon


Brett Cannon  added the comment:

bpo-47025 is a bigger discussion about bytes paths that probably needs to be 
resolved first before worrying about zipimport.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47026] BytesWarning in zipimport paths on sys.path

2022-03-21 Thread Brett Cannon


Change by Brett Cannon :


--
dependencies: +bytes do not work on sys.path

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47026] BytesWarning in zipimport paths on sys.path

2022-03-20 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

This warning can be fixed by changing the following line:

https://github.com/python/cpython/blob/9d1c4d69dbc800ac344565119337fcf490cdc800/Lib/importlib/_bootstrap_external.py#L1419

to:

if not path and str(path) == '':

and running `make regen-importlib; make`

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 Brett as the expert -- Brett, can you take a look?

Adding a full traceback with -bb argument:

Traceback (most recent call last):
  File "/Users/ak/temp2/zipfile_demo.py", line 29, in 
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 "", line 1178, in _find_and_load
  File "", line 1140, in _find_and_load_unlocked
  File "", line 1080, in _find_spec
  File "", line 1493, in find_spec
  File "", line 1462, in _get_spec
  File "", line 1418, in 
_path_importer_cache
BytesWarning: Comparison between bytes and string

--
nosy: +andrei.avk, brett.cannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47026] BytesWarning in zipimport paths on sys.path

2022-03-15 Thread Thomas Grainger


New submission from Thomas Grainger :

importing from a bytes zipimport path on sys.path results in a BytesWarning: 
Comparison between bytes and string

running the reproducer with `python -b` shows:
python -b zipfile_demo.py 
:1345: BytesWarning: Comparison between 
bytes and string

see also https://bugs.python.org/issue47025

--
components: Library (Lib)
files: zipfile_demo.py
messages: 415245
nosy: graingert
priority: normal
severity: normal
status: open
title: BytesWarning in zipimport paths on sys.path
versions: Python 3.10, Python 3.11, Python 3.9
Added file: https://bugs.python.org/file50680/zipfile_demo.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com