From b437f937dcddac9b8790beefab5ccc60d2c6584c Mon Sep 17 00:00:00 2001 From: Ethan Furman Date: Thu, 17 Sep 2015 21:49:12 -0700 Subject: Close issue24840: Enum._value_ is queried for bool(); original patch by Mike Lundy --- Lib/enum.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Lib/enum.py') diff --git a/Lib/enum.py b/Lib/enum.py index c28f3452a7..616b2eac15 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -476,6 +476,9 @@ class Enum(metaclass=EnumMeta): def __str__(self): return "%s.%s" % (self.__class__.__name__, self._name_) + def __bool__(self): + return bool(self._value_) + def __dir__(self): added_behavior = [ m -- cgit v1.2.1 From 6c4c7964cb8671a9aadf025b154ec637d5c358f2 Mon Sep 17 00:00:00 2001 From: Ethan Furman Date: Thu, 17 Sep 2015 22:03:52 -0700 Subject: Close issue25147: use C implementation of OrderedDict --- Lib/enum.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Lib/enum.py') diff --git a/Lib/enum.py b/Lib/enum.py index 616b2eac15..6284b9bb7e 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -1,7 +1,12 @@ import sys -from collections import OrderedDict from types import MappingProxyType, DynamicClassAttribute +try: + from _collections import OrderedDict +except ImportError: + from collections import OrderedDict + + __all__ = ['Enum', 'IntEnum', 'unique'] -- cgit v1.2.1 From 9bbaf4cf4713106e95ed88846df2334dad3c200d Mon Sep 17 00:00:00 2001 From: Ethan Furman Date: Thu, 17 Sep 2015 22:55:40 -0700 Subject: Issue 25147: add reason for using _collections --- Lib/enum.py | 1 + 1 file changed, 1 insertion(+) (limited to 'Lib/enum.py') diff --git a/Lib/enum.py b/Lib/enum.py index 6284b9bb7e..8d04e2d718 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -1,6 +1,7 @@ import sys from types import MappingProxyType, DynamicClassAttribute +# try _collections first to reduce startup cost try: from _collections import OrderedDict except ImportError: -- cgit v1.2.1 From 47bfb98000c9ebaa9f64d9b9f80e80a456279c6b Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Sat, 14 Nov 2015 12:46:42 +0000 Subject: Issue #23883: Add missing APIs to __all__; patch by Jacek Ko?odziej --- Lib/enum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/enum.py') diff --git a/Lib/enum.py b/Lib/enum.py index 8d04e2d718..35a9c77935 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -8,7 +8,7 @@ except ImportError: from collections import OrderedDict -__all__ = ['Enum', 'IntEnum', 'unique'] +__all__ = ['EnumMeta', 'Enum', 'IntEnum', 'unique'] def _is_descriptor(obj): -- cgit v1.2.1