cpython/Lib
Ethan Furman a02cb474f9
bpo-38659: [Enum] add _simple_enum decorator (GH-25497)
add:

* `_simple_enum` decorator to transform a normal class into an enum
* `_test_simple_enum` function to compare
* `_old_convert_` to enable checking `_convert_` generated enums

`_simple_enum` takes a normal class and converts it into an enum:

    @simple_enum(Enum)
    class Color:
        RED = 1
        GREEN = 2
        BLUE = 3

`_old_convert_` works much like` _convert_` does, using the original logic:

    # in a test file
    import socket, enum
    CheckedAddressFamily = enum._old_convert_(
            enum.IntEnum, 'AddressFamily', 'socket',
            lambda C: C.isupper() and C.startswith('AF_'),
            source=_socket,
            )

`_test_simple_enum` takes a traditional enum and a simple enum and
compares the two:

    # in the REPL or the same module as Color
    class CheckedColor(Enum):
        RED = 1
        GREEN = 2
        BLUE = 3

    _test_simple_enum(CheckedColor, Color)

    _test_simple_enum(CheckedAddressFamily, socket.AddressFamily)

Any important differences will raise a TypeError
2021-04-21 10:20:44 -07:00
..
asyncio bpo-41891: ensure asyncio.wait_for waits for task completion (#22461) 2020-12-18 09:26:04 -08:00
collections bpo-43245: Add keyword argument support to ChainMap.new_child() (GH-24788) 2021-03-13 19:15:44 -08:00
concurrent bpo-35930: Raising an exception raised in a "future" instance will create reference cycles (#24995) 2021-03-29 19:22:13 +02:00
ctypes bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25145) 2021-04-04 09:01:23 +09:00
curses
dbm
distutils bpo-41282: Fix distutils.utils.byte_compile() DeprecationWarning (GH-25406) 2021-04-16 11:26:40 +02:00
email bpo-43125: Fix: return expected type (str), not original value (bytes) in email/base64mime.py::body_encode (GH-24476) 2021-03-30 17:37:37 +09:00
encodings
ensurepip bpo-43077: Update bundled pip to 21.0.1 and setuptools to 52.0.0 (GH-24386) 2021-01-30 16:42:36 +00:00
html bpo-41748: Handles unquoted attributes with commas (#24072) 2021-02-01 21:32:50 +01:00
http bpo-38659: [Enum] add _simple_enum decorator (GH-25497) 2021-04-21 10:20:44 -07:00
idlelib bpo-42225: IDLE - document two unix-related problems. (#25078) 2021-03-31 01:19:38 -04:00
importlib bpo-38605: Revert making 'from __future__ import annotations' the default (GH-25490) 2021-04-21 12:41:19 +01:00
json
lib2to3 bpo-43844: Fix PendingDeprecationWarning in test_lib2to3 (GH-25407) 2021-04-16 11:27:00 +02:00
logging bpo-43731: Add an encoding parameter to logging.fileConfig() (GH-25273) 2021-04-13 18:17:03 +09:00
msilib
multiprocessing bpo-43867: multiprocessing Server catchs SystemExit (GH-25441) 2021-04-16 19:42:34 +02:00
pydoc_data Python 3.10.0a7 2021-04-05 17:39:49 +01:00
site-packages
sqlite3 bpo-43296: Handle sqlite3_value_blob() errors (GH-24674) 2021-04-15 00:09:11 +03:00
test bpo-38659: [Enum] add _simple_enum decorator (GH-25497) 2021-04-21 10:20:44 -07:00
tkinter bpo-38659: [Enum] add _simple_enum decorator (GH-25497) 2021-04-21 10:20:44 -07:00
turtledemo Fix typo in turtledemo.two_canvases. (GH-25194) 2021-04-05 13:19:13 -04:00
unittest bpo-43478: Restrict use of Mock objects as specs (GH-25326) 2021-04-09 20:45:50 -07:00
urllib bpo-42967: coerce bytes separator to string in urllib.parse_qs(l) (#24818) 2021-04-11 06:26:09 -07:00
venv
wsgiref
xml bpo-43399: Fix ElementTree.extend not working on iterators (GH-24751) 2021-03-31 00:11:29 +03:00
xmlrpc bpo-43433: Preserve query and fragment in the URL of the server in ServerProxy. (GH-25057) 2021-03-29 22:39:31 +09:00
zoneinfo
__future__.py bpo-35134: Add include/cpython/compile.h (GH-24922) 2021-03-22 09:32:11 +01:00
__phello__.foo.py
_aix_support.py
_bootsubprocess.py
_collections_abc.py bpo-41559: Implement PEP 612 - Add ParamSpec and Concatenate to typing (#23702) 2020-12-23 20:33:48 -08:00
_compat_pickle.py
_compression.py
_markupbase.py
_osx_support.py bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25171) 2021-04-04 17:01:10 +09:00
_py_abc.py
_pydecimal.py
_pyio.py bpo-43680: Deprecate io.OpenWrapper (GH-25357) 2021-04-14 03:24:33 +02:00
_sitebuiltins.py bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25189) 2021-04-06 11:18:41 +09:00
_strptime.py bpo-43295: Fix error handling of datetime.strptime format string '%z' (GH-24627) 2021-03-03 08:58:57 -08:00
_threading_local.py
_weakrefset.py
abc.py
aifc.py
antigravity.py
argparse.py bpo-9694: Fix misleading phrase "optional arguments" (GH-23858) 2020-12-23 09:40:56 -08:00
ast.py bpo-38659: [Enum] add _simple_enum decorator (GH-25497) 2021-04-21 10:20:44 -07:00
asynchat.py
asyncore.py
base64.py bpo-39068: Fix race condition in base64 (GH-17627) 2020-12-31 11:44:46 +02:00
bdb.py bpo-24160: Fix breakpoints persistence across multiple pdb sessions (GH-21989) 2021-04-02 09:15:21 -07:00
binhex.py
bisect.py
bz2.py bpo-43787: Add __iter__ to GzipFile, BZ2File, and LZMAFile (GH-25353) 2021-04-13 13:51:49 +09:00
calendar.py
cgi.py bpo-42967: only use '&' as a query string separator (#24297) 2021-02-14 14:41:57 -08:00
cgitb.py
chunk.py
cmd.py
code.py
codecs.py bpo-14014: Clarify StreamWriter.reset() documentation (GH-13716) 2021-01-06 04:14:42 +02:00
codeop.py bpo-43202: More codeop._maybe_compile clean-ups (GH-24512) 2021-02-13 01:49:18 -05:00
colorsys.py
compileall.py bpo-43651: Fix test_compileall with PEP 597 (GH-25128) 2021-04-02 09:01:57 +09:00
configparser.py bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481) 2021-03-29 12:28:14 +09:00
contextlib.py
contextvars.py
copy.py
copyreg.py
cProfile.py bpo-42005: profile and cProfile catch BrokenPipeError (GH-22643) 2021-01-20 09:56:21 +01:00
crypt.py
csv.py
dataclasses.py bpo-38605: Revert making 'from __future__ import annotations' the default (GH-25490) 2021-04-21 12:41:19 +01:00
datetime.py Fix typo (GH-23019) 2021-02-03 13:25:28 -08:00
decimal.py
difflib.py
dis.py bpo-27129: Use instruction offsets, not byte offsets, in bytecode and internally. (GH-25069) 2021-04-01 16:00:31 +01:00
doctest.py bpo-43049: Use io.IncrementalNewlineDecoder for doctest newline conversion (GH-24359) 2021-03-02 11:06:20 -06:00
enum.py bpo-38659: [Enum] add _simple_enum decorator (GH-25497) 2021-04-21 10:20:44 -07:00
filecmp.py
fileinput.py bpo-43712 : fileinput: Add encoding parameter (GH-25272) 2021-04-14 14:12:58 +09:00
fnmatch.py bpo-36769: Document that fnmatch.filter supports any kind of iterable (#13039) 2020-12-18 20:10:20 +01:00
fractions.py bpo-43420: Simple optimizations for Fraction's arithmetics (GH-24779) 2021-03-21 21:30:55 -05:00
ftplib.py bpo-43285 Make ftplib not trust the PASV response. (GH-24838) 2021-03-15 11:39:31 -07:00
functools.py
genericpath.py
getopt.py
getpass.py
gettext.py
glob.py
graphlib.py
gzip.py bpo-43787: Add __iter__ to GzipFile, BZ2File, and LZMAFile (GH-25353) 2021-04-13 13:51:49 +09:00
hashlib.py bpo-43880: Show DeprecationWarnings for deprecated ssl module features (GH-25455) 2021-04-19 07:27:10 +02:00
heapq.py
hmac.py bpo-40645: use C implementation of HMAC (GH-24920) 2021-03-27 06:55:03 -07:00
imaplib.py
imghdr.py
imp.py bpo-43720: Update import-related stdlib deprecation messages to say they will be removed in Python 3.12 (GH-25167) 2021-04-03 15:31:15 -07:00
inspect.py bpo-38605: Revert making 'from __future__ import annotations' the default (GH-25490) 2021-04-21 12:41:19 +01:00
io.py bpo-43680: Deprecate io.OpenWrapper (GH-25357) 2021-04-14 03:24:33 +02:00
ipaddress.py
keyword.py bpo-42128: Structural Pattern Matching (PEP 634) (GH-22917) 2021-02-26 14:51:55 -08:00
linecache.py
locale.py bpo-34311: Add locale.localize (GH-15275) 2021-04-12 14:17:40 +02:00
lzma.py bpo-43787: Add __iter__ to GzipFile, BZ2File, and LZMAFile (GH-25353) 2021-04-13 13:51:49 +09:00
mailbox.py
mailcap.py
mimetypes.py bpo-43542: Add heif/heic formats in mimetypes (GH-24917) 2021-03-20 16:06:27 -07:00
modulefinder.py
netrc.py
nntplib.py
ntpath.py bpo-39899: Don't double-check directory name if we're requesting the current user's home directory in ntpath.expanduser() (GH-25277) 2021-04-09 22:28:15 +01:00
nturl2path.py
numbers.py
opcode.py bpo-43683: Handle generator entry in bytecode (GH-25138) 2021-04-06 11:48:59 +01:00
operator.py
optparse.py
os.py bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25145) 2021-04-04 09:01:23 +09:00
pathlib.py bpo-40107: Switch to using io.open() for pathlib.Path.open() (GH-25240) 2021-04-09 21:52:49 +01:00
pdb.py bpo-26053: Fix args echoed by pdb run command (#22033) 2021-04-01 08:25:59 -07:00
pickle.py bpo-42406: Fix whichmodule() with multiprocessing (GH-23403) 2020-11-29 10:23:15 -08:00
pickletools.py
pipes.py
pkgutil.py bpo-43720: Update import-related stdlib deprecation messages to say they will be removed in Python 3.12 (GH-25167) 2021-04-03 15:31:15 -07:00
platform.py handle empty string in variable executable in platform.libc_ver() (#23140) 2021-01-02 17:03:53 +01:00
plistlib.py bpo-40066: Enum: modify repr() and str() (GH-22392) 2021-03-30 21:17:26 -07:00
poplib.py
posixpath.py bpo-31904: posixpath.expanduser() handles None user home on VxWorks (GH-23530) 2020-12-17 20:22:29 +01:00
pprint.py bpo-43080: pprint for dataclass instances (GH-24389) 2021-04-13 19:59:24 -04:00
profile.py bpo-42005: profile and cProfile catch BrokenPipeError (GH-22643) 2021-01-20 09:56:21 +01:00
pstats.py bpo-38659: [Enum] add _simple_enum decorator (GH-25497) 2021-04-21 10:20:44 -07:00
pty.py
py_compile.py
pyclbr.py bpo-40443: Remove unused imports (GH-25429) 2021-04-16 11:26:06 +02:00
pydoc.py bpo-42988: Remove the pydoc getfile feature (GH-25015) 2021-03-29 14:40:40 +02:00
queue.py
quopri.py
random.py Improve the error message for choices(population, 10) (GH-25267) 2021-04-19 20:29:48 -07:00
re.py bpo-38659: [Enum] add _simple_enum decorator (GH-25497) 2021-04-21 10:20:44 -07:00
reprlib.py
rlcompleter.py
runpy.py bpo-41718: runpy now imports pkgutil in functions (GH-24996) 2021-03-23 19:22:57 +01:00
sched.py
secrets.py
selectors.py
shelve.py
shlex.py
shutil.py bpo-41718: subprocess imports grp and pwd on demand (GH-24987) 2021-03-23 17:42:51 +01:00
signal.py
site.py bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481) 2021-03-29 12:28:14 +09:00
smtpd.py
smtplib.py bpo-27820: Fix AUTH LOGIN logic in smtplib.SMTP (GH-24118) 2021-03-12 15:25:49 -08:00
sndhdr.py
socket.py
socketserver.py bpo-37193: Remove thread objects which finished process its request (GH-23127) 2020-12-31 20:19:30 +00:00
sre_compile.py
sre_constants.py
sre_parse.py
ssl.py bpo-38659: [Enum] add _simple_enum decorator (GH-25497) 2021-04-21 10:20:44 -07:00
stat.py
statistics.py bpo-43147: Remove archaic terminology. (GH-24462) 2021-02-07 16:44:42 -08:00
string.py
stringprep.py
struct.py
subprocess.py bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481) 2021-03-29 12:28:14 +09:00
sunau.py
symtable.py
sysconfig.py bpo-41282: (PEP 632) Load install schemes from sysconfig (GH-24549) 2021-04-14 17:12:34 +02:00
tabnanny.py
tarfile.py bpo-39717: [tarfile] update nested exception raising (GH-23739) 2020-12-12 13:26:44 -08:00
telnetlib.py
tempfile.py bpo-43510: Implement PEP 597 opt-in EncodingWarning. (GH-19481) 2021-03-29 12:28:14 +09:00
textwrap.py
this.py
threading.py bpo-43723: Deprecate camelCase aliases from threading (GH-25174) 2021-04-12 10:42:53 +02:00
timeit.py
token.py bpo-43822: Improve syntax errors for missing commas (GH-25377) 2021-04-15 21:38:45 +01:00
tokenize.py bpo-43014: Improve performance of tokenize.tokenize by 20-30% 2021-01-24 12:23:17 +03:00
trace.py Fix typo in Lib/trace.py (GH-24309) 2021-02-01 21:16:38 +05:30
traceback.py bpo-43146: fix None-handling in single-arg traceback.print_exception(None) (GH-24629) 2021-02-23 09:43:04 -08:00
tracemalloc.py bpo-37961: Fix regression in tracemalloc.Traceback.__repr__ (GH-23805) 2020-12-16 22:38:32 +01:00
tty.py
turtle.py
types.py bpo-38250: [Enum] single-bit flags are canonical (GH-24215) 2021-01-25 14:26:19 -08:00
typing.py bpo-38605: Revert making 'from __future__ import annotations' the default (GH-25490) 2021-04-21 12:41:19 +01:00
uu.py
uuid.py bpo-38659: [Enum] add _simple_enum decorator (GH-25497) 2021-04-21 10:20:44 -07:00
warnings.py
wave.py
weakref.py
webbrowser.py
xdrlib.py
zipapp.py
zipfile.py bpo-42090: zipfile.Path.joinpath now accepts multiple arguments (GH-22976) 2020-12-15 18:12:54 -08:00
zipimport.py bpo-42135: Deprecate implementations of find_module() and find_loader() (GH-25169) 2021-04-06 08:56:57 -07:00