Skip to content

Commit dd02380

Browse files
authored
Merge branch 'main' into hy/close_issue_137942
2 parents 6516250 + b07a267 commit dd02380

File tree

15 files changed

+2473
-497
lines changed

15 files changed

+2473
-497
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ struct _Py_global_strings {
787787
STRUCT_FOR_ID(template)
788788
STRUCT_FOR_ID(term)
789789
STRUCT_FOR_ID(text)
790+
STRUCT_FOR_ID(third)
790791
STRUCT_FOR_ID(threading)
791792
STRUCT_FOR_ID(throw)
792793
STRUCT_FOR_ID(time)

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_runtime_init_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_call.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,14 @@ def c_py_recurse(m):
10741074
with self.assertRaises(RecursionError):
10751075
c_py_recurse(100_000)
10761076

1077+
def test_recursion_with_kwargs(self):
1078+
# GH-137883: The interpreter forgot to check the recursion limit when
1079+
# calling with keywords.
1080+
def recurse_kw(a=0):
1081+
recurse_kw(a=0)
1082+
with self.assertRaises(RecursionError):
1083+
recurse_kw()
1084+
10771085

10781086
class TestFunctionWithManyArgs(unittest.TestCase):
10791087
def test_function_with_many_args(self):

Lib/test/test_dis.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ def foo(x):
830830
%4d LOAD_GLOBAL 1 (list + NULL)
831831
LOAD_FAST_BORROW 0 (x)
832832
BUILD_TUPLE 1
833-
LOAD_CONST 1 (<code object <genexpr> at 0x..., file "%s", line %d>)
833+
LOAD_CONST %d (<code object <genexpr> at 0x..., file "%s", line %d>)
834834
MAKE_FUNCTION
835835
SET_FUNCTION_ATTRIBUTE 8 (closure)
836836
LOAD_DEREF 1 (y)
@@ -842,6 +842,7 @@ def foo(x):
842842
_h.__code__.co_firstlineno + 1,
843843
_h.__code__.co_firstlineno + 1,
844844
_h.__code__.co_firstlineno + 3,
845+
1 if __debug__ else 0,
845846
__file__,
846847
_h.__code__.co_firstlineno + 3,
847848
)
@@ -1468,7 +1469,7 @@ def get_disassembly(self, func, lasti=-1, wrapper=True, **kwargs):
14681469
Kw-only arguments: 0
14691470
Number of locals: 1
14701471
Stack size: \\d+
1471-
Flags: OPTIMIZED, NEWLOCALS, HAS_DOCSTRING
1472+
Flags: OPTIMIZED, NEWLOCALS(, HAS_DOCSTRING)?
14721473
Constants:
14731474
{code_info_consts}
14741475
Names:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix runaway recursion when calling a function with keyword arguments.

0 commit comments

Comments
 (0)