[Python-checkins] cpython (2.7): Issue #23998: PyImport_ReInitLock() now checks for lock allocation error

christian.heimes python-checkins at python.org
Sun Apr 19 21:15:49 CEST 2015


https://hg.python.org/cpython/rev/d70995cf44b3
changeset:   95716:d70995cf44b3
branch:      2.7
parent:      95705:df28044b7e14
user:        Christian Heimes <christian at python.org>
date:        Sun Apr 19 21:08:28 2015 +0200
summary:
  Issue #23998: PyImport_ReInitLock() now checks for lock allocation error

files:
  Misc/NEWS       |  2 ++
  Python/import.c |  6 +++++-
  2 files changed, 7 insertions(+), 1 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -263,6 +263,8 @@
 C API
 -----
 
+- Issue #23998: PyImport_ReInitLock() now checks for lock allocation error
+
 - Issue #22079: PyType_Ready() now checks that statically allocated type has
   no dynamically allocated bases.
 
diff --git a/Python/import.c b/Python/import.c
--- a/Python/import.c
+++ b/Python/import.c
@@ -337,8 +337,12 @@
 void
 _PyImport_ReInitLock(void)
 {
-    if (import_lock != NULL)
+    if (import_lock != NULL) {
         import_lock = PyThread_allocate_lock();
+        if (import_lock == NULL) {
+            Py_FatalError("PyImport_ReInitLock failed to create a new lock");
+        }
+    }
     import_lock_thread = -1;
     import_lock_level = 0;
 }

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list