]> granicus.if.org Git - python/commitdiff
Merged revisions 83411 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Sun, 1 Aug 2010 16:57:17 +0000 (16:57 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Sun, 1 Aug 2010 16:57:17 +0000 (16:57 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83411 | antoine.pitrou | 2010-08-01 18:53:42 +0200 (dim., 01 août 2010) | 4 lines

  Issue #9448: Fix a leak of OS resources (mutexes or semaphores) when
  re-initializing a buffered IO object by calling its `__init__` method.
........

Misc/NEWS
Modules/_io/bufferedio.c

index 713e42293e53fd02e79bd2d92c9cb3ba3a6a0dc9..6c51aa6608b4103494742d59c876505d2f228198 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -24,6 +24,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #9448: Fix a leak of OS resources (mutexes or semaphores) when
+  re-initializing a buffered IO object by calling its ``__init__`` method.
+
 - Issue #8471: In doctest, properly reset the output stream to an empty
   string when Unicode was previously output.
 
index feee9be0087de9bdb1ea8e920c7ba239d4a482f0..9a14d26590eef6735da4373f32a241691617ccdc 100644 (file)
@@ -636,6 +636,8 @@ _buffered_init(buffered *self)
         return -1;
     }
 #ifdef WITH_THREAD
+    if (self->lock)
+        PyThread_free_lock(self->lock);
     self->lock = PyThread_allocate_lock();
     if (self->lock == NULL) {
         PyErr_SetString(PyExc_RuntimeError, "can't allocate read lock");