Simon Percivall added the comment: Run this a couple of times (it fails for me the first time, but it's a race, so YMMV):
``` import enum from concurrent.futures import ThreadPoolExecutor class MyEnum(enum.IntFlag): one = 1 with ThreadPoolExecutor() as executor: print(list(executor.map(MyEnum.one.__or__, range(1000)))) ``` An easy fix would be: ``` diff --git a/Lib/enum.py b/Lib/enum.py index e79b0382eb..eca56ec3a7 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -846,7 +846,7 @@ def _decompose(flag, value): # check for named flags and powers-of-two flags flags_to_check = [ (m, v) - for v, m in flag._value2member_map_.items() + for v, m in list(flag._value2member_map_.items()) if m.name is not None or _power_of_two(v) ] members = [] ``` ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29167> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com