summaryrefslogtreecommitdiffstats
path: root/Lib/logging/__init__.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-01-07 17:03:23 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2020-01-07 17:03:23 (GMT)
commitbff48c6734f936257b0cfae58dbea67d43e3b245 (patch)
tree1571b1e1836aa11ffa837cab957155f926b76951 /Lib/logging/__init__.py
parent4112a3da2e01ecc19e9f54b8ac7b383b6f5e85c8 (diff)
downloadcpython-bff48c6734f936257b0cfae58dbea67d43e3b245.zip
cpython-bff48c6734f936257b0cfae58dbea67d43e3b245.tar.gz
cpython-bff48c6734f936257b0cfae58dbea67d43e3b245.tar.bz2
bpo-39198: Ensure logging global lock is released on exception in isEnabledFor (GH-17689) (GH-17897)
(cherry picked from commit 950c6795aa0ffa85e103a13e7a04e08cb34c66ad)
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 16812ec..0cfaec8 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -1685,12 +1685,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):