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:
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)
Activity
sunmy2019 commented on May 6, 2023
This behavior change is probably due to the new Enum implementation in 3.11. Also confirmed on 3.11.
No need to backport to 3.10.