Repository navigation
python -m inspect --details fails in nondecodable directory #69370
Copy link
Copy link
Closed
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
$ pwd /home/serhiy/py/cpy�thon-3.5 $ ./python -m inspect --details unittest Target: unittest Traceback (most recent call last): File "/home/serhiy/py/cpy\udcffthon-3.5/Lib/runpy.py", line 170, in _run_module_as_main "__main__", mod_spec) File "/home/serhiy/py/cpy\udcffthon-3.5/Lib/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/serhiy/py/cpy\udcffthon-3.5/Lib/inspect.py", line 3050, in <module> _main() File "/home/serhiy/py/cpy\udcffthon-3.5/Lib/inspect.py", line 3030, in _main print('Origin: {}'.format(getsourcefile(module))) UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 27: surrogates not allowed
- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Sep 19, 2015 On Python 3.11 when creating a directory containing \udcff I receive the following error that happens even when I'm not running the inspect module.
sam@samtop /tmp/bpo/python\M-^?-3.11 (git)-[main] % ./python Exception ignored error evaluating path: Traceback (most recent call last): File "<frozen getpath>", line 348, in <module> ModuleNotFoundError: No module named 'encodings' Fatal Python error: error evaluating path Python runtime state: core initialized Current thread 0x00007f6594655740 (most recent call first): <no Python frame> 1 sam@samtop /tmp/bpo/python\M-^?-3.11 (git)-[main] %
- added3.11only security fixesonly security fixes3.10 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of life
on Apr 23, 2022 ./python -m inspectcan maybe reconfigure sys.stdout to use a different error handler than strict? Like backslashreplace or replace. I don't think that it's worth it to add special code just to display "Origin: ", many other strings can contain characters not encoding to stdout encoding (UTF-8 in your case).Does it work to just add:
sys.stdout.reconfigure(errors="backslashreplace")?- added a commit that references this issue
on Aug 29, 2026 - added a commit that references this issue
on Oct 10, 2026
Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
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:
Linked PRs