This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ethan.furman
Recipients ethan.furman
Date 2021-03-31.14:25:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617200705.39.0.678751580159.issue43681@roundup.psfhosted.org>
In-reply-to
Content
In the Python 3.10 Doc/library/enum.rst file was the following:

.. class:: FlagBoundary

   *FlagBoundary* controls how out-of-range values are handled in *Flag* and its
   subclasses.

   .. attribute:: STRICT

      Out-of-range values cause a :exc:`ValueError` to be raised.  This is the
      default for :class:`Flag`::

         >>> from enum import STRICT
         >>> class StrictFlag(Flag, boundary=STRICT):
         ...     RED = auto()
         ...     GREEN = auto()
         ...     BLUE = auto()
         >>> StrictFlag(2**2 + 2**4)
         Traceback (most recent call last):
         ...
         ValueError: StrictFlag: invalid value: 20
             given 0b0 10100
           allowed 0b0 00111

   .. attribute:: CONFORM

      Out-of-range values have invalid values removed, leaving a valid *Flag*
      value::

         >>> from enum import CONFORM
         >>> class ConformFlag(Flag, boundary=CONFORM):
         ...     RED = auto()
         ...     GREEN = auto()
         ...     BLUE = auto()
         >>> ConformFlag(2**2 + 2**4)
         ConformFlag.BLUE

   .. attribute:: EJECT

      Out-of-range values lose their *Flag* membership and revert to :class:`int`.
      This is the default for :class:`IntFlag`::

         >>> from enum import EJECT
         >>> class EjectFlag(Flag, boundary=EJECT):
         ...     RED = auto()
         ...     GREEN = auto()
         ...     BLUE = auto()
         >>> EjectFlag(2**2 + 2**4)
         20

   .. attribute:: KEEP

      Out-of-range values are kept, and the *Flag* membership is kept.  This is
      used for some stdlib flags:

         >>> from enum import KEEP
         >>> class KeepFlag(Flag, boundary=KEEP):
         ...     RED = auto()
         ...     GREEN = auto()
         ...     BLUE = auto()
         >>> KeepFlag(2**2 + 2**4)
         KeepFlag.BLUE|0x10


All four tests are relying on a previous `from enum import Flag`, but only the three tests pass -- the fourth raises:

    Traceback (most recent call last):
      File "/home/runner/work/cpython/cpython/Lib/doctest.py", line 1337, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest default[1]>", line 1, in <module>
        class KeepFlag(Flag, boundary=KEEP):
    NameError: name 'Flag' is not defined
History
Date User Action Args
2021-03-31 14:25:05ethan.furmansetrecipients: + ethan.furman
2021-03-31 14:25:05ethan.furmansetmessageid: <1617200705.39.0.678751580159.issue43681@roundup.psfhosted.org>
2021-03-31 14:25:05ethan.furmanlinkissue43681 messages
2021-03-31 14:25:05ethan.furmancreate