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

Broken help() on metaclasses #79795

Closed
serhiy-storchaka opened this issue Dec 29, 2018 · 4 comments
Closed

Broken help() on metaclasses #79795

serhiy-storchaka opened this issue Dec 29, 2018 · 4 comments
Labels
3.8 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 35614
Nosy @ncoghlan, @abalkin, @merwok, @serhiy-storchaka, @CuriousLearner
PRs
  • bpo-35614: Fix pydoc help() on metaclasses #11357
  • bpo-35614: Fix pydoc help() on metaclasses #11357
  • bpo-35614: Fix pydoc help() on metaclasses #11357
  • 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 2018-12-31.05:19:43.925>
    created_at = <Date 2018-12-29.15:21:50.099>
    labels = ['3.8', 'type-bug', 'library']
    title = 'Broken help() on metaclasses'
    updated_at = <Date 2018-12-31.05:19:43.924>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-12-31.05:19:43.924>
    actor = 'ncoghlan'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-12-31.05:19:43.925>
    closer = 'ncoghlan'
    components = ['Library (Lib)']
    creation = <Date 2018-12-29.15:21:50.099>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35614
    keywords = ['patch', 'patch', 'patch']
    message_count = 4.0
    messages = ['332720', '332726', '332727', '332802']
    nosy_count = 5.0
    nosy_names = ['ncoghlan', 'belopolsky', 'eric.araujo', 'serhiy.storchaka', 'CuriousLearner']
    pr_nums = ['11357', '11357', '11357']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue35614'
    versions = ['Python 3.8']

    @serhiy-storchaka
    Copy link
    Member Author

    $ ./python -m pydoc abc
    Traceback (most recent call last):
      File "/home/serhiy/py/cpython/Lib/runpy.py", line 192, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/home/serhiy/py/cpython/Lib/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 2765, in <module>
        cli()
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 2727, in cli
        help.help(arg)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1967, in help
        elif request: doc(request, 'Help on %s:', output=self._output)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1690, in doc
        pager(render_doc(thing, title, forceload))
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1683, in render_doc
        return title % desc + '\n\n' + renderer.document(object, name)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 385, in document
        if inspect.ismodule(object): return self.docmodule(*args)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1182, in docmodule
        contents.append(self.document(value, key, name))
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 386, in document
        if inspect.isclass(object): return self.docclass(*args)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1258, in docclass
        (str(cls.__name__) for cls in object.__subclasses__()
    TypeError: descriptor '__subclasses__' of 'type' object needs an argument
    
    $ ./python -m pydoc enum
    Traceback (most recent call last):
      File "/home/serhiy/py/cpython/Lib/runpy.py", line 192, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/home/serhiy/py/cpython/Lib/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 2765, in <module>
        cli()
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 2727, in cli
        help.help(arg)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1967, in help
        elif request: doc(request, 'Help on %s:', output=self._output)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1690, in doc
        pager(render_doc(thing, title, forceload))
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1683, in render_doc
        return title % desc + '\n\n' + renderer.document(object, name)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 385, in document
        if inspect.ismodule(object): return self.docmodule(*args)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1182, in docmodule
        contents.append(self.document(value, key, name))
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 386, in document
        if inspect.isclass(object): return self.docclass(*args)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1258, in docclass
        (str(cls.__name__) for cls in object.__subclasses__()
    TypeError: descriptor '__subclasses__' of 'type' object needs an argument

    "object" is a metaclass (abc.ABCMeta or enum.EnumMeta) in tracebacks above.

    The regression was introduced in bpo-8525.

    @serhiy-storchaka serhiy-storchaka added 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 29, 2018
    @serhiy-storchaka
    Copy link
    Member Author

    It fails also for builtin "type".

    $ ./python -m pydoc type
    Traceback (most recent call last):
      File "/home/serhiy/py/cpython/Lib/runpy.py", line 192, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/home/serhiy/py/cpython/Lib/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 2765, in <module>
        cli()
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 2727, in cli
        help.help(arg)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1967, in help
        elif request: doc(request, 'Help on %s:', output=self._output)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1690, in doc
        pager(render_doc(thing, title, forceload))
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1683, in render_doc
        return title % desc + '\n\n' + renderer.document(object, name)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 386, in document
        if inspect.isclass(object): return self.docclass(*args)
      File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1258, in docclass
        (str(cls.__name__) for cls in object.__subclasses__()
    TypeError: descriptor '__subclasses__' of 'type' object needs an argument

    @serhiy-storchaka
    Copy link
    Member Author

    There are two ways of solving this issue: 1) skip this chunk of code if object is a type subclass, 2) use type.__subclasses__(object) instead of object.__subclasses__().

    @ncoghlan
    Copy link
    Contributor

    New changeset b539cef by Nick Coghlan (Sanyam Khurana) in branch 'master':
    bpo-35614: Fix pydoc help() on metaclasses (bpo-11357)
    b539cef

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 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

    2 participants