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

Pydoc fails for test.test_enum #116600

Closed
serhiy-storchaka opened this issue Mar 11, 2024 · 3 comments
Closed

Pydoc fails for test.test_enum #116600

serhiy-storchaka opened this issue Mar 11, 2024 · 3 comments
Assignees
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Mar 11, 2024

Bug report

$ ./python -m pydoc test.test_enum
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
           ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
                     "__main__", mod_spec)
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/runpy.py", line 88, in _run_code
    exec(code, run_globals)
    ~~~~^^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 2948, in <module>
    cli()
    ~~~^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 2909, in cli
    help.help(arg, is_cli=True)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 2165, in help
    elif request: doc(request, 'Help on %s:', output=self._output, is_cli=is_cli)
                  ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1881, in doc
    pager(render_doc(thing, title, forceload))
          ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1874, in render_doc
    return title % desc + '\n\n' + renderer.document(object, name)
                                   ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 521, in document
    if inspect.ismodule(object): return self.docmodule(*args)
                                        ~~~~~~~~~~~~~~^^^^^^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1341, in docmodule
    contents.append(self.document(value, key, name))
                    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 522, in document
    if inspect.isclass(object): return self.docclass(*args)
                                       ~~~~~~~~~~~~~^^^^^^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1512, in docclass
    attrs = spilldata("Data and other attributes %s:\n" % tag, attrs,
            ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                      lambda t: t[1] == 'data')
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1475, in spilldata
    push(self.docother(obj, name, mod, maxlen=70, doc=doc) +
         ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1620, in docother
    repr = self.repr(object)
           ~~~~~~~~~^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/reprlib.py", line 60, in repr
    return self.repr1(x, self.maxlevel)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/pydoc.py", line 1213, in repr1
    return cram(stripid(repr(x)), self.maxother)
                        ~~~~^^^
  File "/home/serhiy/py/cpython/Lib/enum.py", line 1685, in global_flag_repr
    if _is_single_bit(self):
       ~~~~~~~~~~~~~~^^^^^^
  File "/home/serhiy/py/cpython/Lib/enum.py", line 96, in _is_single_bit
    num &= num - 1
           ~~~~^~~
TypeError: unsupported operand type(s) for -: 'NoName' and 'int'

cc @ethanfurman

Linked PRs

@serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error 3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes labels Mar 11, 2024
@serhiy-storchaka
Copy link
Member Author

Simpler reproducer:

>>> import test.test_enum
>>> test.test_enum.NoName
<flag 'NoName'>
>>> repr(test.test_enum.NoName.ONE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    repr(test.test_enum.NoName.ONE)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/serhiy/py/cpython/Lib/enum.py", line 1685, in global_flag_repr
    if _is_single_bit(self):
       ~~~~~~~~~~~~~~^^^^^^
  File "/home/serhiy/py/cpython/Lib/enum.py", line 96, in _is_single_bit
    num &= num - 1
           ~~~~^~~
TypeError: unsupported operand type(s) for -: 'NoName' and 'int'

@serhiy-storchaka
Copy link
Member Author

And the reproducer without using test.test_enum:

import enum
@enum.global_enum
class NoName(enum.Flag):
    ONE = 1

print(repr(ONE))

@Eclips4 Eclips4 added the stdlib Python modules in the Lib dir label Mar 11, 2024
@ethanfurman ethanfurman self-assigned this Mar 11, 2024
@ethanfurman
Copy link
Member

I thought those tests were supposed to run during the CI?

ethanfurman added a commit that referenced this issue Mar 11, 2024
* and fix global flag repr

* Update Misc/NEWS.d/next/Library/2024-03-11-12-11-10.gh-issue-116600.FcNBy_.rst

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Mar 11, 2024
* and fix global flag repr

* Update Misc/NEWS.d/next/Library/2024-03-11-12-11-10.gh-issue-116600.FcNBy_.rst

(cherry picked from commit 06e29a2)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Mar 11, 2024
* and fix global flag repr

* Update Misc/NEWS.d/next/Library/2024-03-11-12-11-10.gh-issue-116600.FcNBy_.rst

(cherry picked from commit 06e29a2)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
ethanfurman added a commit that referenced this issue Mar 12, 2024
* and fix global flag repr

(cherry picked from commit 06e29a2)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
ethanfurman added a commit that referenced this issue Mar 12, 2024
* and fix global flag repr

(cherry picked from commit 06e29a2)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
adorilson pushed a commit to adorilson/cpython that referenced this issue Mar 25, 2024
* and fix global flag repr

* Update Misc/NEWS.d/next/Library/2024-03-11-12-11-10.gh-issue-116600.FcNBy_.rst

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
* and fix global flag repr

* Update Misc/NEWS.d/next/Library/2024-03-11-12-11-10.gh-issue-116600.FcNBy_.rst

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and 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