diff --git a/Lib/threading.py b/Lib/threading.py index 178c8fd33ca..24808d43b83 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -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 = "" % ident + format = "%s: %s\n" % (name, format) _sys.stderr.write(format) else: diff --git a/Misc/NEWS b/Misc/NEWS index a49b34488c0..e53aff0dcba 100644 --- 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.