]> granicus.if.org Git - python/commitdiff
Merged revisions 87341 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Fri, 17 Dec 2010 17:44:45 +0000 (17:44 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Fri, 17 Dec 2010 17:44:45 +0000 (17:44 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r87341 | antoine.pitrou | 2010-12-17 18:42:16 +0100 (ven., 17 déc. 2010) | 4 lines

  Issue #4188: Avoid creating dummy thread objects when logging operations
  from the threading module (with the internal verbose flag activated).
........

Lib/threading.py
Misc/NEWS

index 178c8fd33ca2030c7c77f541cbe341abaf9d5838..24808d43b839a550c003a737d1f78c6ae2f9d41d 100644 (file)
@@ -50,8 +50,14 @@ if __debug__:
         def _note(self, format, *args):
             if self._verbose:
                 format = format % args
-                format = "%s: %s\n" % (
-                    current_thread().name, format)
+                # Issue #4188: calling current_thread() can incur an infinite
+                # recursion if it has to create a DummyThread on the fly.
+                ident = _get_ident()
+                try:
+                    name = _active[ident].name
+                except KeyError:
+                    name = "<OS thread %d>" % ident
+                format = "%s: %s\n" % (name, format)
                 _sys.stderr.write(format)
 
 else:
index a49b34488c007c0628e7a5e78f6be68d7427b039..e53aff0dcba36a9bac12b5d52d04ab2ef70e5dff 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -20,6 +20,10 @@ Core and Builtins
 
 Library
 -------
+
+- Issue #4188: Avoid creating dummy thread objects when logging operations
+  from the threading module (with the internal verbose flag activated).
+
 - Issue #9721: Fix the behavior of urljoin when the relative url starts with a
   ';' character. Patch by Wes Chow.