summaryrefslogtreecommitdiffstats
path: root/Lib/enum.py
Commit message (Collapse)AuthorAgeFilesLines
* [Enum] improve pickle support (#26666)Ethan Furman2021-06-111-3/+27
| | | | search all bases for a __reduce__ style method; if a __new__ method is found first the enum will be made unpicklable
* bpo-44356: [Enum] allow multiple data-type mixins if they are all the same ↵Miss Islington (bot)2021-06-101-4/+4
| | | | | | | | | | | | | | | | | | | (GH-26649) (GH-26652) This enables, for example, two base Enums to both inherit from `str`, and then both be mixed into the same final Enum: class Str1Enum(str, Enum): GH- some behavior here class Str2Enum(str, Enum): GH- some more behavior here class FinalStrEnum(Str1Enum, Str2Enum): GH- this now works (cherry picked from commit 8a4f0850d75747af8c96ca0e7eef1f5c1abfba25) Co-authored-by: Ethan Furman <ethan@stoneleaf.us> Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* [3.9] bpo-42248: [Enum] ensure exceptions raised in ``_missing_`` are ↵Ethan Furman2021-04-121-13/+18
| | | | | | | released (GH-25350). (GH-25370) (cherry picked from commit 8c14f5a787b21d5a1eae5d5ee981431d1c0e055f) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* [3.9] bpo-42851: [Enum] remove brittle __init_subclass__ support (GH-24154) ↵Ethan Furman2021-01-071-30/+1
| | | | | | (GH-24155) Solution to support calls to `__init_subclass__` with members defined is too brittle and breaks with certain mixins.. (cherry picked from commit a581a868d97f649aedf868a1d27865a10925c73a)
* bpo-42727: [Enum] use super() and include **kwds (GH-23927)Miss Islington (bot)2020-12-251-2/+2
| | | | | | | | | for multiple inheritance support: use super().new pass **kwds to super().new (cherry picked from commit 786d97a66cac48e7a933010367b8993a5b3ab85b) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* [3.9] bpo-42727: [Enum] EnumMeta.__prepare__ now accepts **kwds (GH-23917). ↵Ethan Furman2020-12-241-1/+1
| | | | | | (GH-23926) * [3.9] [Enum] EnumMeta.__prepare__ now accepts **kwds (GH-23917). (cherry picked from commit 6ec0adefad60ec7cdec61c44baecf1dccc1461ab)
* [3.9] bpo-42567: [Enum] call __init_subclass__ after members are added ↵Ethan Furman2020-12-151-2/+30
| | | | | | | | (GH-23714) (GH-23772) When creating an Enum, `type.__new__` calls `__init_subclass__`, but at that point the members have not been added. This patch suppresses the initial call, then manually calls the ancestor `__init_subclass__` before returning the new Enum class. (cherry picked from commit 6bd94de168b58ac9358277ed6f200490ab26c174)
* [3.9] bpo-42517: [Enum] deprecate private name members (GH-23722) (GH-23748)Miss Islington (bot)2020-12-141-0/+22
| | | private names will raise a DeprecationWarning; in 3.10 they will become normal attributes
* bpo-40084: Enum - dir() includes member attributes (GH-19219)Miss Islington (bot)2020-12-141-1/+1
| | | | | (cherry picked from commit 68526fe258da8c01196fd7cf48e8e5f1280bf8fd) Co-authored-by: Angelin BOOZ <9497359+lem2clide@users.noreply.github.com>
* [3.9] [Enum] reformat and add doc strings (GH-23705). (GH-23707)Ethan Furman2020-12-081-51/+127
| | | * [3.9] [Enum] reformat and add doc strings (GH-23705).
* bpo-41907: [Enum] fix format() behavior for IntFlag (GH-22497) (GH-23703)Miss Islington (bot)2020-12-081-1/+1
| | | (cherry picked from commit 37440eef7f9a0c27e13fc9ce0850574bb00688b0)
* bpo-41889: [Enum] fix multiple-inheritance regression (GH-22487) (GH-23673)Miss Islington (bot)2020-12-071-3/+8
| | | (cherry picked from commit c266736ec1f9ebef38b134ceb4832df015711b38)
* [3.9] bpo-39728: Enum: fix duplicate `ValueError` (GH-22277) (GH-22282)Ethan Furman2020-09-171-1/+1
| | | | | | | fix default `_missing_` to return `None` instead of raising a `ValueError` Co-authored-by: Andrey Darascheka <andrei.daraschenka@leverx.com> (cherry picked from commit c95ad7a91fbd7636f33a098d3b39964ab083bf49) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* _auto_called cleanup (GH-22285)Miss Islington (bot)2020-09-171-1/+1
| | | | | (cherry picked from commit fc23a9483ef0d7c98bea9f82392377d0b6ef7b18) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* bpo-41517: do not allow Enums to be extended (GH-22271)Miss Islington (bot)2020-09-161-5/+14
| | | | | | fix bug that let Enums be extended via multiple inheritance (cherry picked from commit 3064dbf5df1021e85b507366a7ea448c8895efe7) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* [3.9] bpo-41789: honor object overrides in Enum classes (GH-22250) (GH-22272)Ethan Furman2020-09-161-0/+4
| | | EnumMeta double-checks that `__repr__`, `__str__`, `__format__`, and `__reduce_ex__` are not the same as `object`'s, and replaces them if they are -- even if that replacement was intentionally done in the Enum being constructed. This patch fixes that.
* bpo-39587: Enum - use correct mixed-in data type (GH-22263) (GH-22266)Miss Islington (bot)2020-09-151-1/+12
| | | (cherry picked from commit bff01f3a3aac0c15fe8fbe8b2f561f7927d117a1)
* bpo-40025: Require _generate_next_value_ to be defined before members (GH-19098)Ethan Onstott2020-04-281-0/+5
| | | require `_generate_next_value_` to be defined before members
* bpo-38045: Improve the performance of _decompose() in enum.py (GH-16483)HongWeipeng2019-11-261-23/+10
| | | | | | * Improve the performance of _decompose() in enum.py Co-Authored-By: Brandt Bucher <brandtbucher@gmail.com>
* Remove binding of captured exceptions when not used to reduce the chances of ↵Pablo Galindo2019-11-191-1/+1
| | | | | | | creating cycles (GH-17246) Capturing exceptions into names can lead to reference cycles though the __traceback__ attribute of the exceptions in some obscure cases that have been reported previously and fixed individually. As these variables are not used anyway, we can remove the binding to reduce the chances of creating reference cycles. See for example GH-13135
* Doc: Fix spelling errors of 'initial' in enum.py (GH-16314)HongWeipeng2019-09-211-1/+1
|
* bpo-34443: Use __qualname__ instead of __name__ in enum exception messages. ↵Walter Dörwald2019-07-181-4/+4
| | | | | (GH-14809) * Use __qualname__ instead of __name__ in enum exception messages.
* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden ↵thatneat2019-07-041-2/+3
| | | | | __str__ (GH-14545) * bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__
* bpo-34282: Remove deprecated enum _convert method (GH-13823)Zachary Ware2019-06-041-6/+0
|
* bpo-35899: Fix Enum handling of empty and weird strings (GH-11891)Brennan D Baraban2019-03-031-8/+9
| | | | | | | | | | Co-authored-by: Maxwell <maxwellpxt@gmail.com> Co-authored-by: Stéphane Wirtel <stephane@wirtel.be> https://bugs.python.org/issue35899
* bpo-35717: Fix KeyError exception raised when using enums and compile (GH-11523)Rémi Lapeyre2019-01-241-1/+1
| | | https://bugs.python.org/issue17467
* Speed-up building enums by value, e.g. http.HTTPStatus(200) (#11318)Andrew Svetlov2018-12-261-2/+4
| | | bpo-35585: Speed up enum by-value lookup
* bpo-34909: keep searching mixins until base class is found (GH-9737)Ethan Furman2018-10-061-3/+1
|
* bpo-29577: Enum: mixin classes don't mix well with already mixed Enums (GH-9328)Ethan Furman2018-09-221-31/+19
| | | * bpo-29577: allow multiple mixin classes
* bpo-34536: raise error for invalid _missing_ results (GH-9147)Ethan Furman2018-09-121-1/+19
| | | * raise exception if _missing_ returns None or invalid type
* bpo-34282: Fix Enum._convert shadowing members named _convert (GH-8568)orlnub1232018-09-121-38/+45
| | | | | * Fix enum members getting shadowed by parent attributes * Move Enum._convert to EnumMeta._convert_ * Deprecate _convert
* bpo-33217: Raise TypeError for non-Enum lookups in Enums (GH-6651)Rahul Jha2018-09-101-1/+7
| | | * bpo-33217: Raise TypeError for non-Enum lookups in Enums
* bpo-33866: enum: Stop using OrderedDict (GH-7698)INADA Naoki2018-06-181-13/+5
|
* bpo-31947: remove None default for names param in Enum._create_ (GH-4288)anentropic2018-04-161-1/+1
|
* bpo-31801: Enum: add _ignore_ as class option (#5237)Ethan Furman2018-01-221-1/+19
| | | | | | | | | | | | | | | | * bpo-31801: Enum: add _ignore_ as class option _ignore_ is a list, or white-space seperated str, of names that will not be candidates for members; these names, and _ignore_ itself, are removed from the final class. * bpo-31801: Enum: add documentation for _ignore_ * bpo-31801: Enum: remove trailing whitespace * bpo-31801: Enum: fix bulleted list format * bpo-31801: add version added for _ignore_
* bpo-30152: Reduce the number of imports for argparse. (#1269)Serhiy Storchaka2017-09-251-7/+4
|
* Spelling fixes (#2902)Ville Skyttä2017-08-031-1/+1
|
* bpo-30616: Functional API of enum allows to create empty enums. (#2304)Dong-hee Na2017-06-211-1/+1
| | | | | | | | * bpo-30616: Functional API of enum allows to create empty enums. * Update NEWS move addition to avoid conflict
* closes issue29167: fix race condition in (Int)FlagEthan Furman2017-01-241-4/+11
|
* Issue #29103: Remove unused import. Noticed by Jean-Sebastien Bevilacqua.Raymond Hettinger2016-12-301-1/+1
|
* close issue28172: Change all example enum member names to uppercase, per ↵Ethan Furman2016-11-211-2/+2
| | | | Guido; patch by Chris Angelico.
* issue23591: fix flag decomposition and reprEthan Furman2016-09-181-58/+94
|
* Enum._convert: sort by value, then by nameEthan Furman2016-09-111-3/+10
|
* issue23591: add auto() for auto-generating Enum member valuesEthan Furman2016-09-111-13/+37
|
* issue23591: more docs; slight change to reprEthan Furman2016-09-041-8/+5
|
* issue23591: bool(empty_flags) == False; more docs & testsEthan Furman2016-09-021-0/+3
|
* issue23591: optimize _high_bit()Ethan Furman2016-09-021-7/+2
|
* issue23591: add docs; code cleanup; more testsEthan Furman2016-09-021-4/+4
|
* issue23591: add Flags, IntFlags, and testsEthan Furman2016-08-311-10/+217
|
* issue26981: add _order_ compatibility shim to enum.EnumEthan Furman2016-08-201-2/+15
|