summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2009-11-27 14:03:36 +0000
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2009-11-27 14:03:36 +0000
commite9c5a0410e55a7ef5a3ca9cab1df46ecfeb367a2 (patch)
tree4b7b62c637f2b8073a40681dc246f93a741e02ea
parent546b2121ffda7ed3ce6426fa16071e09ea9b39b0 (diff)
downloadcpython-git-e9c5a0410e55a7ef5a3ca9cab1df46ecfeb367a2.tar.gz
Issue #7403: Fixed possible race condition in lock creation.
-rw-r--r--Lib/logging/__init__.py8
-rw-r--r--Misc/NEWS2
2 files changed, 6 insertions, 4 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 3fe03cdeb6..03c67b0204 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -186,7 +186,10 @@ def addLevelName(level, levelName):
#the lock would already have been acquired - so we need an RLock.
#The same argument applies to Loggers and Manager.loggerDict.
#
-_lock = None
+if thread:
+ _lock = threading.RLock()
+else:
+ _lock = None
def _acquireLock():
"""
@@ -194,9 +197,6 @@ def _acquireLock():
This should be released with _releaseLock().
"""
- global _lock
- if (not _lock) and thread:
- _lock = threading.RLock()
if _lock:
_lock.acquire()
diff --git a/Misc/NEWS b/Misc/NEWS
index 746e3422dd..ca36adcdb7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -33,6 +33,8 @@ Core and Builtins
Library
-------
+- Issue #7403: logging: Fixed possible race condition in lock creation.
+
- Issue #7341: Close the internal file object in the TarFile constructor in
case of an error.