summaryrefslogtreecommitdiffstats
path: root/Lib/logging/__init__.py
diff options
context:
space:
mode:
authorDerek Brown <derek@allderek.com>2020-01-07 16:40:23 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2020-01-07 16:40:23 (GMT)
commit950c6795aa0ffa85e103a13e7a04e08cb34c66ad (patch)
treedb44f0644d4fadec34da5f55c9460e1623f7f52f /Lib/logging/__init__.py
parent5b23f7618d434f3000bde482233c8642a6eb2c67 (diff)
downloadcpython-950c6795aa0ffa85e103a13e7a04e08cb34c66ad.zip
cpython-950c6795aa0ffa85e103a13e7a04e08cb34c66ad.tar.gz
cpython-950c6795aa0ffa85e103a13e7a04e08cb34c66ad.tar.bz2
bpo-39198: Ensure logging global lock is released on exception in isEnabledFor (GH-17689)
Diffstat (limited to 'Lib/logging/__init__.py')
-rw-r--r--Lib/logging/__init__.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 62a87a7..59d5fa5 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -1687,12 +1687,15 @@ class Logger(Filterer):
return self._cache[level]
except KeyError:
_acquireLock()
- if self.manager.disable >= level:
- is_enabled = self._cache[level] = False
- else:
- is_enabled = self._cache[level] = level >= self.getEffectiveLevel()
- _releaseLock()
-
+ try:
+ if self.manager.disable >= level:
+ is_enabled = self._cache[level] = False
+ else:
+ is_enabled = self._cache[level] = (
+ level >= self.getEffectiveLevel()
+ )
+ finally:
+ _releaseLock()
return is_enabled
def getChild(self, suffix):