Skip to content

Commit a727ed0

Browse files
ZeroIntensitykumaraditya303
authored andcommitted
[3.14] pythongh-137883: Check the recursion limit for specialized keyword argument calls (pythonGH-137887) (python#137945)
Co-authored-by: Peter Bierma <[email protected]>
1 parent 05a5e63 commit a727ed0

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

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.

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):
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.

Python/bytecodes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4740,6 +4740,7 @@ dummy_func(
47404740
unused/1 + // Skip over the counter
47414741
_CHECK_PEP_523 +
47424742
_CHECK_FUNCTION_VERSION_KW +
4743+
_CHECK_RECURSION_REMAINING +
47434744
_PY_FRAME_KW +
47444745
_SAVE_RETURN_OFFSET +
47454746
_PUSH_FRAME;

Python/generated_cases.c.h

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

0 commit comments

Comments
 (0)