Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
serhiy-storchaka opened this issue Sep 19, 2015 · 4 comments
Open

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

serhiy-storchaka opened this issue Sep 19, 2015 · 4 comments
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

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']

@serhiy-storchaka
Copy link
Member Author

$ 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

@serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 19, 2015
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@dignissimus
Copy link
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] % 

@serhiy-storchaka serhiy-storchaka added 3.11 only security fixes 3.10 only security fixes 3.9 only security fixes labels Apr 23, 2022
@vstinner
Copy link
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).

@vstinner
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes 3.10 only security fixes 3.11 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants