Skip to content

pydoc: HTMLDoc.index() doesn't support PEP 383 #55395

Closed

Description

@vstinner
BPO 11186
Nosy @malemburg, @loewis, @vstinner, @merwok

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 = <Date 2011-04-12.21:45:14.038>
created_at = <Date 2011-02-11.12:55:09.147>
labels = ['library', 'docs']
title = "pydoc: HTMLDoc.index() doesn't support PEP 383"
updated_at = <Date 2011-04-15.17:13:52.312>
user = 'https://github.com/vstinner'

bugs.python.org fields:

activity = <Date 2011-04-15.17:13:52.312>
actor = 'eric.araujo'
assignee = 'docs@python'
closed = True
closed_date = <Date 2011-04-12.21:45:14.038>
closer = 'vstinner'
components = ['Documentation', 'Library (Lib)']
creation = <Date 2011-02-11.12:55:09.147>
creator = 'vstinner'
dependencies = []
files = []
hgrepos = []
issue_num = 11186
keywords = []
message_count = 6.0
messages = ['128382', '128383', '133604', '133668', '133670', '133851']
nosy_count = 6.0
nosy_names = ['lemburg', 'loewis', 'vstinner', 'eric.araujo', 'docs@python', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue11186'
versions = ['Python 3.1', 'Python 3.2', 'Python 3.3']

Activity

  1. vstinner commented on Feb 11, 2011

    @vstinner
    MemberAuthor

    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:

    def isUndecodableFilename(filename):
      return any((0xD800 <= ord(ch) <= 0xDFFF) for ch in filename)

    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).

  2. added
    docsDocumentation in the Doc dir
    stdlibStandard Library Python modules in the Lib/ directory
    on Feb 11, 2011
  3. vstinner commented on Feb 11, 2011

    @vstinner
    MemberAuthor

    Oops, my isUndecodableFilename() example is wrong. PEP-383 only uses U+DC80..U+DCFF range:

    def isUndecodableFilename(filename):
      return any((0xDC80 <= ord(ch) <= 0xDCFF) for ch in filename)

    Example of undecodable filename: b'bla\xe9\xff.py' with UTF-8 filesystem encoding is decoded as 'bla\uDCE9\uDCFF.py'.

  4. python-dev commented on Apr 12, 2011

    python-devmannequin
    Mannequin

    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

  5. merwok commented on Apr 13, 2011

    @merwok
    Member

    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?

  6. vstinner commented on Apr 13, 2011

    @vstinner
    MemberAuthor

    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.

    (It is possible to import such module using __import__, but it is just ugly)

    For the changelog, feel free to rephrase it.

  7. merwok commented on Apr 15, 2011

    @merwok
    Member

    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.

  8. transferred this issue fromon Apr 10, 2022
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

    docsDocumentation in the Doc dirstdlibStandard Library Python modules in the Lib/ directory

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions