From: Ned Deily Date: Sat, 28 May 2011 07:45:52 +0000 (-0700) Subject: Issue #9670: Increase the default stack size for secondary threads on X-Git-Tag: v3.3.0a1~2183^2~71 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=61be422bd73784615249d3dfe28c0a8f322b5d65;p=python Issue #9670: Increase the default stack size for secondary threads on Mac OS X and FreeBSD to reduce the chances of a crash instead of a "maximum recursion depth" RuntimeError exception. (patch by Ronald Oussoren) --- 61be422bd73784615249d3dfe28c0a8f322b5d65 diff --cc Lib/test/test_threading.py index 2dc77733f7,416d95f68d..c22d965495 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@@ -699,10 -692,37 +700,41 @@@ class ThreadingExceptionTests(BaseTestC thread.start() self.assertRaises(RuntimeError, setattr, thread, "daemon", True) + def test_releasing_unacquired_lock(self): + lock = threading.Lock() + self.assertRaises(RuntimeError, lock.release) + + @unittest.skipUnless(sys.platform == 'darwin', 'test macosx problem') + def test_recursion_limit(self): + # Issue 9670 + # test that excessive recursion within a non-main thread causes + # an exception rather than crashing the interpreter on platforms + # like Mac OS X or FreeBSD which have small default stack sizes + # for threads + script = """if True: + import threading + + def recurse(): + return recurse() + + def outer(): + try: + recurse() + except RuntimeError: + pass + + w = threading.Thread(target=outer) + w.start() + w.join() + print('end of main thread') + """ + expected_output = "end of main thread\n" + p = subprocess.Popen([sys.executable, "-c", script], + stdout=subprocess.PIPE) + stdout, stderr = p.communicate() + data = stdout.decode().replace('\r', '') + self.assertEqual(p.returncode, 0, "Unexpected error") + self.assertEqual(data, expected_output) class LockTests(lock_tests.LockTests): locktype = staticmethod(threading.Lock) diff --cc Misc/NEWS index 9c00590e06,e5267aa2e8..3238406e67 --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -10,14 -10,25 +10,19 @@@ What's New in Python 3.3 Alpha 1 Core and Builtins ----------------- + - Issue #9670: Increase the default stack size for secondary threads on + Mac OS X and FreeBSD to reduce the chances of a crash instead of a + "maximum recursion depth" RuntimeError exception. + (patch by Ronald Oussoren) + -Library -------- - -- Issue #12175: RawIOBase.readall() now returns None if read() returns None. - -- Issue #12175: FileIO.readall() now raises a ValueError instead of an IOError - if the file is closed. +- Issue #12106: The use of the multiple-with shorthand syntax is now reflected + in the AST. -- Issue #12070: Fix the Makefile parser of the sysconfig module to handle - correctly references to "bogus variable" (e.g. "prefix=$/opt/python"). +- Issue #12190: Try to use the same filename object when compiling unmarshalling + a code objects in the same file. -- Issue #12100: Don't reset incremental encoders of CJK codecs at each call to - their encode() method anymore, but continue to call the reset() method if the - final argument is True. +- Issue #12166: Move implementations of dir() specialized for various types into + the __dir__() methods of those types. - Issue #5715: In socketserver, close the server socket in the child process.