diff --git a/Languages/IronPython/IronPython/Runtime/PythonOptions.cs b/Languages/IronPython/IronPython/Runtime/PythonOptions.cs index 050de18999..c660da1dc5 100644 --- a/Languages/IronPython/IronPython/Runtime/PythonOptions.cs +++ b/Languages/IronPython/IronPython/Runtime/PythonOptions.cs @@ -268,7 +268,10 @@ public PythonOptions(IDictionary options) _optimize = GetOption(options, "Optimize", false); _stripDocStrings = GetOption(options, "StripDocStrings", false); _division = GetOption(options, "DivisionOptions", PythonDivisionOptions.Old); - _recursionLimit = GetOption(options, "RecursionLimit", Int32.MaxValue); + _recursionLimit = GetOption(options, "RecursionLimit", 2000); + // CPython has 1000 as default recursion limit, which is reported (e.g. www.stackoverflow.com) to be somewhat + // conservative. Not limiting recursion on the other hand obfuscates user code issues and the + // resulting StackOverflowException be interpreted as an interpreter bug. _indentationInconsistencySeverity = GetOption(options, "IndentationInconsistencySeverity", Severity.Ignore); _enableProfiler = GetOption(options, "EnableProfiler", false); _lightweightScopes = GetOption(options, "LightweightScopes", false); diff --git a/Languages/IronPython/Tests/test_sys.py b/Languages/IronPython/Tests/test_sys.py new file mode 100644 index 0000000000..3e83146dba --- /dev/null +++ b/Languages/IronPython/Tests/test_sys.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +##################################################################################### +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# This source code is subject to terms and conditions of the Apache License, Version 2.0. A +# copy of the license can be found in the License.html file at the root of this distribution. If +# you cannot locate the Apache License, Version 2.0, please send an email to +# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound +# by the terms of the Apache License, Version 2.0. +# +# You must not remove this notice, or any other, from this software. +# +# +##################################################################################### + +## +## Test builtin sys module +## + +import sys +from iptest.assert_util import * + +def test_recursionlimit_default(): + # we don't care the exact value, but recursion should be limited by default + Assert(sys.getrecursionlimit() < 10000) + +run_test(__name__) diff --git a/Test/IronPython.tests b/Test/IronPython.tests index 4e2322ba9c..d2c576eece 100644 --- a/Test/IronPython.tests +++ b/Test/IronPython.tests @@ -229,6 +229,17 @@ false %DLR_ROOT%\Languages\IronPython\Tests + + test_sys_20 + %DLR_ROOT%\Languages\IronPython\Internal\ipy.bat + test_sys.py + 600000 + false + false + false + false + %DLR_ROOT%\Languages\IronPython\Tests + test_tuple_20 %DLR_ROOT%\Languages\IronPython\Internal\ipy.bat