From: Antoine Pitrou Date: Fri, 17 Dec 2010 17:42:16 +0000 (+0000) Subject: Issue #4188: Avoid creating dummy thread objects when logging operations X-Git-Tag: v3.2b2~41 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=401edd69cf23f7f102aece55e05157daf1b87f9f;p=thirdparty%2FPython%2Fcpython.git Issue #4188: Avoid creating dummy thread objects when logging operations from the threading module (with the internal verbose flag activated). --- diff --git a/Lib/threading.py b/Lib/threading.py index b6c1e5ddab9d..01c27b85e6d6 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -55,8 +55,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 = "" % ident + format = "%s: %s\n" % (name, format) _sys.stderr.write(format) else: diff --git a/Misc/NEWS b/Misc/NEWS index 6e618924abc2..94116ce55a1a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -20,6 +20,9 @@ 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 #10711: Remove HTTP 0.9 support from http.client. The ``strict`` parameter to HTTPConnection and friends is deprecated.