Skip to content

python -m inspect --details fails in nondecodable directory #69370

Description

@serhiy-storchaka
BPO 25183
Nosy @serhiy-storchaka, @1st1

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:

assignee = None
closed_at = None
created_at = <Date 2015-09-19.20:57:40.554>
labels = ['type-bug', 'library']
title = 'python -m inspect --details fails in nondecodable directory'
updated_at = <Date 2015-09-21.12:03:02.733>
user = 'https://github.com/serhiy-storchaka'

bugs.python.org fields:

activity = <Date 2015-09-21.12:03:02.733>
actor = 'Arfrever'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2015-09-19.20:57:40.554>
creator = 'serhiy.storchaka'
dependencies = []
files = []
hgrepos = []
issue_num = 25183
keywords = []
message_count = 1.0
messages = ['251116']
nosy_count = 3.0
nosy_names = ['Arfrever', 'serhiy.storchaka', 'yselivanov']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue25183'
versions = ['Python 3.4', 'Python 3.5', 'Python 3.6']

Linked PRs

Activity

  1. serhiy-storchaka commented on Sep 19, 2015

    @serhiy-storchaka
    MemberAuthor
    $ 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
  2. added
    stdlibStandard Library Python modules in the Lib/ directory
    type-bugAn unexpected behavior, bug, or error
    on Sep 19, 2015
  3. transferred this issue fromon Apr 10, 2022
  4. dignissimus commented on Apr 23, 2022

    @dignissimus
    Contributor

    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] % 
  5. vstinner commented on Sep 22, 2023

    @vstinner
    Member

    ./python -m inspect can 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).

  6. vstinner commented on Sep 22, 2023

    @vstinner
    Member

    Does it work to just add: sys.stdout.reconfigure(errors="backslashreplace")?

  7. added a commit that references this issue on Aug 29, 2026
  8. added 2 commits that reference this issue on Aug 29, 2026
  9. added a commit that references this issue on Sep 12, 2026
  10. added a commit that references this issue on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10 (EOL)end of life3.11only security fixes3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions