summaryrefslogtreecommitdiff
path: root/Lib/enum.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2015-09-17 21:49:12 -0700
committerEthan Furman <ethan@stoneleaf.us>2015-09-17 21:49:12 -0700
commit6db1fd5fb8b2287cd4713c95f0df451e375c8853 (patch)
tree9f44e78118615583ad7064d1a800adcef6c254c4 /Lib/enum.py
parentb1a3d9ae561b7b5a0bbbb47fad2f98448f1c7419 (diff)
downloadcpython-git-6db1fd5fb8b2287cd4713c95f0df451e375c8853.tar.gz
Close issue24840: Enum._value_ is queried for bool(); original patch by Mike Lundy
Diffstat (limited to 'Lib/enum.py')
-rw-r--r--Lib/enum.py3
1 files changed, 3 insertions, 0 deletions
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