Ethan Furman
6bd94de168
bpo-42567: [Enum] call __init_subclass__ after members are added (GH-23714)
...
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.
2020-12-09 16:41:22 -08:00
Ethan Furman
6d3dfee271
[Enum] reformat and add doc strings (GH-23705)
2020-12-08 12:26:56 -08:00
Ethan Furman
37440eef7f
bpo-41907: [Enum] fix format() behavior for IntFlag (GH-22497)
2020-12-08 11:14:10 -08:00
Ethan Furman
c266736ec1
bpo-41889: [Enum] fix multiple-inheritance regression (GH-22487)
2020-12-07 00:17:31 -08:00
Ethan Furman
d986d1657e
bpo-41816: StrEnum.__str__ is str.__str__ (GH-22362)
...
use `str.__str__` for `StrEnum` so that `str(StrEnum.member)` is the same as directly accessing the string value of the `StrEnum` member
2020-09-22 13:00:07 -07:00
Ethan Furman
0063ff4e58
bpo-41816: add StrEnum (GH-22337)
...
`StrEnum` ensures that its members were already strings, or intended to
be strings.
2020-09-21 17:23:13 -07:00
Angelin BOOZ
68526fe258
bpo-40084: Enum - dir() includes member attributes (GH-19219)
2020-09-21 06:11:06 -07:00
Ethan Furman
7219e27087
Enum: make Flag and IntFlag members iterable (GH-22221)
2020-09-16 13:01:00 -07:00
Ethan Furman
fc23a9483e
_auto_called cleanup (GH-22285)
2020-09-16 12:37:54 -07:00
Ethan Furman
c95ad7a91f
bpo-39728: Enum: fix duplicate ValueError (GH-22277)
...
fix default `_missing_` to return `None` instead of raising a `ValueError`
Co-authored-by: Andrey Darascheka <andrei.daraschenka@leverx.com >
2020-09-16 10:26:50 -07:00
Ethan Furman
3064dbf5df
bpo-41517: do not allow Enums to be extended ( #22271 )
...
fix bug that let Enums be extended via multiple inheritance
2020-09-16 07:11:57 -07:00
Ethan Furman
22415ad625
bpo-41789: honor object overrides in Enum classes (GH-22250)
...
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.
Automerge-Triggered-By: @ethanfurman
2020-09-15 16:28:25 -07:00
Ethan Furman
bff01f3a3a
bpo-39587: Enum - use correct mixed-in data type (GH-22263)
2020-09-15 15:56:26 -07:00
Zackery Spytz
2ec67526a6
bpo-38967: Improve the error msg for reserved _sunder_ names in enum (GH-18370)
2020-09-13 13:27:51 -07:00
Ethan Onstott
d9a43e20fa
bpo-40025: Require _generate_next_value_ to be defined before members (GH-19098)
...
require `_generate_next_value_` to be defined before members
2020-04-28 10:20:55 -07:00
HongWeipeng
0b41a922f9
bpo-38045: Improve the performance of _decompose() in enum.py (GH-16483)
...
* Improve the performance of _decompose() in enum.py
Co-Authored-By: Brandt Bucher <brandtbucher@gmail.com >
2019-11-26 14:36:02 -08:00
Pablo Galindo
293dd23477
Remove binding of captured exceptions when not used to reduce the chances of 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
2019-11-19 21:34:03 +00:00
HongWeipeng
bb16fb2cb8
Doc: Fix spelling errors of 'initial' in enum.py (GH-16314)
2019-09-21 07:22:54 +02:00
Walter Dörwald
323842c279
bpo-34443: Use __qualname__ instead of __name__ in enum exception messages. (GH-14809)
...
* Use __qualname__ instead of __name__ in enum exception messages.
2019-07-18 11:37:13 -07:00
thatneat
2f19e82fbe
bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__ (GH-14545)
...
* bpo-37479: on Enum subclasses with mixins, __format__ uses overridden __str__
2019-07-04 11:28:37 -07:00
Zachary Ware
19a1e1eb86
bpo-34282: Remove deprecated enum _convert method (GH-13823)
2019-06-04 23:03:10 +02:00
Brennan D Baraban
8b914d2767
bpo-35899: Fix Enum handling of empty and weird strings (GH-11891)
...
Co-authored-by: Maxwell <maxwellpxt@gmail.com >
Co-authored-by: Stéphane Wirtel <stephane@wirtel.be >
https://bugs.python.org/issue35899
2019-03-03 14:09:11 -08:00
Rémi Lapeyre
1fd06f1eca
bpo-35717: Fix KeyError exception raised when using enums and compile (GH-11523)
...
https://bugs.python.org/issue17467
2019-01-24 11:43:13 -08:00
Andrew Svetlov
34ae04f74d
Speed-up building enums by value, e.g. http.HTTPStatus(200) ( #11318 )
...
bpo-35585: Speed up enum by-value lookup
2018-12-26 10:45:33 -08:00
Ethan Furman
cd45385ffa
bpo-34909: keep searching mixins until base class is found (GH-9737)
2018-10-05 23:29:36 -07:00