New submission from Thomas Grainger <tagr...@gmail.com>:
importing a module with bytes in `sys.path` fails with: File "<frozen importlib._bootstrap_external>", 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 bytes "Only strings and bytes should be added to sys.path; all other data types are ignored during import." https://docs.python.org/3/library/sys.html?highlight=Only%20strings%20and%20bytes#sys.path bytes are allowed in PathFinder._find_spec https://github.com/python/cpython/blob/2cf7f865f099db11cc6903b334d9c376610313e8/Lib/importlib/_bootstrap_external.py#L1460-L1462 but perhaps they should be ignored or explicitly fsdecoded ? see also: https://bugs.python.org/issue32642 https://github.com/python/importlib_metadata/issues/372#issuecomment-1067799424 ---------- files: demo.py messages: 415233 nosy: graingert priority: normal severity: normal status: open title: bytes do not work on sys.path Added file: https://bugs.python.org/file50678/demo.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue47025> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com