Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb48465

Browse files
committed
On Max OSX, try increasing the stack limit to 2048 so test_re and
test_sre won't die with a SegFault.
1 parent 5f7c4b3 commit bb48465

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lib/test/regrtest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@
8383
warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning,
8484
"<string>")
8585

86+
# MacOSX (a.k.a. Darwin) has a default stack size that is too small
87+
# for deeply recursive regular expressions. We see this as crashes in
88+
# the Python test suite when running test_re.py and test_sre.py. The
89+
# fix is to set the stack limit to 2048.
90+
# This approach may also be useful for other Unixy platforms that
91+
# suffer from small default stack limits.
92+
if sys.platform == 'darwin':
93+
try:
94+
import resource
95+
except ImportError:
96+
pass
97+
else:
98+
soft, hard = resource.getrlimit(resource.RLIMIT_STACK)
99+
newsoft = min(hard, max(soft, 1024*2048))
100+
resource.setrlimit(resource.RLIMIT_STACK, (newsoft, hard))
101+
86102
from test import test_support
87103

88104
RESOURCE_NAMES = ('curses', 'largefile', 'network', 'bsddb')

0 commit comments

Comments
 (0)