-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
3.12 documentation for enum.Enum.__dir__ says that this method returns "['__class__', '__doc__', '__module__', 'name', 'value'] and any public methods defined on self.__class__", but this is not true, e.g. when using the code provided:
>>> from enum import Enum
>>> from datetime import date
>>> class Weekday(Enum):
... MONDAY = 1
... TUESDAY = 2
... WEDNESDAY = 3
... THURSDAY = 4
... FRIDAY = 5
... SATURDAY = 6
... SUNDAY = 7
... @classmethod
... def today(cls):
... print('today is %s' % cls(date.today().isoweekday()).name)
...
>>> dir(Weekday.SATURDAY)
['FRIDAY', 'MONDAY', 'SATURDAY', 'SUNDAY', 'THURSDAY', 'TUESDAY', 'WEDNESDAY', '__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']Also it seems that test_enum has bug in it, because it doesn't detect the error above if invoked through libregrtest (as ./python -m test test_enum), but direct run of test_enum or doctest on enum documentation fails:
$ ./python -m test.test_enum
...........................................................................................................................................s.s......s........................................................................................................................................................................................................................................................................................................................s...........................................s...............................................................................................F
======================================================================
FAIL: /home/chgnrdv/cpython/Lib/test/../../Doc/library/enum.rst
Doctest: enum.rst
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/chgnrdv/cpython/Lib/doctest.py", line 2228, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for enum.rst
File "/home/chgnrdv/cpython/Lib/test/../../Doc/library/enum.rst", line 0
----------------------------------------------------------------------
File "/home/chgnrdv/cpython/Lib/test/../../Doc/library/enum.rst", line 297, in enum.rst
Failed example:
dir(Weekday.SATURDAY)
Expected:
['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']
Got:
['FRIDAY', 'MONDAY', 'SATURDAY', 'SUNDAY', 'THURSDAY', 'TUESDAY', 'WEDNESDAY', '__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']
----------------------------------------------------------------------
Ran 602 tests in 5.113s
FAILED (failures=1, skipped=5)
./python -m doctest Doc/library/enum.rst
**********************************************************************
File "Doc/library/enum.rst", line 297, in enum.rst
Failed example:
dir(Weekday.SATURDAY)
Expected:
['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']
Got:
['FRIDAY', 'MONDAY', 'SATURDAY', 'SUNDAY', 'THURSDAY', 'TUESDAY', 'WEDNESDAY', '__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']
**********************************************************************
1 items had failures:
1 of 88 in enum.rst
***Test Failed*** 1 failures.
I'm working on fixes for both errors.
Linked PRs
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error