[issue47025] bytes do not work on sys.path

2022-03-17 Thread Brett Cannon
Brett Cannon added the comment: I think it depends on whether we want to say the standard/included/built-in import mechanisms don't support byte paths, or byte paths are entirely not supported even for 3rd-party code? I definitely think we should at least do the former, but I'm hesitant to

[issue47025] bytes do not work on sys.path

2022-03-17 Thread Brett Cannon
Change by Brett Cannon : -- nosy: +brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue47025] bytes do not work on sys.path

2022-03-16 Thread Thomas Grainger
Thomas Grainger added the comment: > I'd advocate for not supporting bytes paths and instead updating the > documentation to require strings. I've got PR GH-31934 started to do this -- message_count: 8.0 -> 9.0 pull_requests: +30026 pull_request:

[issue47025] bytes do not work on sys.path

2022-03-15 Thread Jason R. Coombs
Jason R. Coombs added the comment: I'd advocate for not supporting bytes paths and instead updating the documentation to require strings. -- nosy: +jaraco ___ Python tracker

[issue47025] bytes do not work on sys.path

2022-03-15 Thread Thomas Grainger
Thomas Grainger added the comment: zipimporter.zipimporter handles non-bytes paths here: https://github.com/python/cpython/blob/2cf7f865f099db11cc6903b334d9c376610313e8/Lib/zipimport.py#L65-L67 I think FileFinder should do the same -- ___ Python

[issue47025] bytes do not work on sys.path

2022-03-15 Thread Eryk Sun
Eryk Sun added the comment: > this is a regression from 3.2 In Windows, bytes paths in sys.path do not work in 3.2+. I didn't test 3.0 and 3.1, but practically one can say that bytes paths were never supported in Python 3 on Windows. -- nosy: +eryksun

[issue47025] bytes do not work on sys.path

2022-03-15 Thread Thomas Grainger
Thomas Grainger added the comment: interestingly bytes filenames pointing to zip files on sys.path do support bytes (see zipfile_demo.py) -- Added file: https://bugs.python.org/file50679/zipfile_demo.py ___ Python tracker

[issue47025] bytes do not work on sys.path

2022-03-15 Thread Thomas Grainger
Thomas Grainger added the comment: https://docs.python.org/3/reference/import.html#path-entry-finders says "The encoding of bytes entries is determined by the individual path entry finders." see https://github.com/python/cpython/commit/82c1c781c7ee6496bd4c404b7ba972eed5dbcb12 --

[issue47025] bytes do not work on sys.path

2022-03-15 Thread Thomas Grainger
Thomas Grainger added the comment: this is a regression from 3.2: ``` Python 3.2.6 (default, Jan 18 2016, 19:21:14) [GCC 4.9.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tempfile >>> tempfile.TemporaryDirectory() >>> v = _ >>> tmp_dir =

[issue47025] bytes do not work on sys.path

2022-03-15 Thread Eric V. Smith
Eric V. Smith added the comment: In case it helps anyone: On Windows 3.11.0a5+ the full traceback is: $ ./python.bat demo.py Running Debug|x64 interpreter... Traceback (most recent call last): File "...\demo.py", line 23, in sys.exit(main()) ^^ File

[issue47025] bytes do not work on sys.path

2022-03-15 Thread Thomas Grainger
Change by Thomas Grainger : -- keywords: +patch pull_requests: +29993 stage: -> patch review pull_request: https://github.com/python/cpython/pull/31897 ___ Python tracker ___

[issue47025] bytes do not work on sys.path

2022-03-15 Thread Thomas Grainger
Change by Thomas Grainger : -- components: +Library (Lib) versions: +Python 3.10, Python 3.11, Python 3.9 ___ Python tracker ___

[issue47025] bytes do not work on sys.path

2022-03-15 Thread Thomas Grainger
New submission from Thomas Grainger : importing a module with bytes in `sys.path` fails with: File "", line 182, in _path_isabs TypeError: startswith first arg must be bytes or a tuple of bytes, not str (see reproducer in attached demo.py) however `sys.path` is documented as supporting