You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pydoc: HTMLDoc.index() doesn't support PEP 383 #55395
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=Noneclosed_at=<Date2011-04-12.21:45:14.038>created_at=<Date2011-02-11.12:55:09.147>labels= ['library', 'docs']
title="pydoc: HTMLDoc.index() doesn't support PEP 383"updated_at=<Date2011-04-15.17:13:52.312>user='https://github.com/vstinner'
If you have an undecodable filenames on UNIX, Python 3 escapes undecodable bytes using surrogates. pydoc: HTMLDoc.index() uses indirectly os.listdir() which does such operation, and later filenames are encoded to UTF-8 (the whole HTML content is encoded to UTF-8).
In practice, you cannot import such .py file, you run them using "python script.py", so we can maybe just ignore modules with undecodable filenames. For example:
Or we can escape the surrogate characters, but I don't know how. Write "\uDC80" in a HTML document is not a good idea, especially in an URL (e.g. Firefox replaces \ by / in URLs).
The wording “pydoc ignores a module” is confusing to me: I can’t tell whether it is a description of the bug (“pydoc ignored a module”) or the new, correct behavior (“pydoc now ignores a module”).
Regarding the problem and fix itself, I’m wondering. If a user unknowingly creates such a module with an unencodable filename, will they understand why pydoc does not display it?
It is really a bad idea to choose an *undecodable* name for a module.
You will not be able to write its name using "import name" syntax.
Okay, makes sense that pydoc ignores those. You speak about a user choosing to create such a filename though; is it possible to create such a name without knowing it?
For the changelog, feel free to rephrase it.
I don’t currently have SSH access, so please do it.
Activity
vstinner commentedon Feb 11, 2011
If you have an undecodable filenames on UNIX, Python 3 escapes undecodable bytes using surrogates. pydoc: HTMLDoc.index() uses indirectly os.listdir() which does such operation, and later filenames are encoded to UTF-8 (the whole HTML content is encoded to UTF-8).
In practice, you cannot import such .py file, you run them using "python script.py", so we can maybe just ignore modules with undecodable filenames. For example:
Or we can escape the surrogate characters, but I don't know how. Write "\uDC80" in a HTML document is not a good idea, especially in an URL (e.g. Firefox replaces \ by / in URLs).
vstinner commentedon Feb 11, 2011
Oops, my isUndecodableFilename() example is wrong. PEP-383 only uses U+DC80..U+DCFF range:
Example of undecodable filename: b'bla\xe9\xff.py' with UTF-8 filesystem encoding is decoded as 'bla\uDCE9\uDCFF.py'.
python-dev commentedon Apr 12, 2011
New changeset 506cab8fc329 by Victor Stinner in branch 'default':
Issue bpo-11186: pydoc ignores a module if its name contains a surrogate character
http://hg.python.org/cpython/rev/506cab8fc329
merwok commentedon Apr 13, 2011
The wording “pydoc ignores a module” is confusing to me: I can’t tell whether it is a description of the bug (“pydoc ignored a module”) or the new, correct behavior (“pydoc now ignores a module”).
Regarding the problem and fix itself, I’m wondering. If a user unknowingly creates such a module with an unencodable filename, will they understand why pydoc does not display it?
vstinner commentedon Apr 13, 2011
It is really a bad idea to choose an *undecodable* name for a module. You will not be able to write its name using "import name" syntax.
(It is possible to import such module using __import__, but it is just ugly)
For the changelog, feel free to rephrase it.
merwok commentedon Apr 15, 2011
Okay, makes sense that pydoc ignores those. You speak about a user choosing to create such a filename though; is it possible to create such a name without knowing it?
I don’t currently have SSH access, so please do it.