From d19d6476a32b04c496734389a48db3e1cc584ba1 Mon Sep 17 00:00:00 2001 From: Guangshuo CHEN Date: Mon, 10 Sep 2018 15:54:02 +0800 Subject: [PATCH] fix the WeakSet keyError bug --- tqdm/_tqdm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index 71e05b2a..e80091be 100755 --- a/tqdm/_tqdm.py +++ b/tqdm/_tqdm.py @@ -478,7 +478,9 @@ class tqdm(Comparable): """ with cls._lock: try: - cls._instances.remove(instance) + if instance in cls._instances: + # in python2 instance maybe magically removed from cls._instances + cls._instances.remove(instance) except KeyError: if not instance.gui: # pragma: no cover raise