Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
increment CO_MAXBLOCKS
  • Loading branch information
iritkatriel committed Apr 29, 2024
commit f29d7bf02e642096cd8b2c8fe3160a890cd45031
2 changes: 1 addition & 1 deletion Include/cpython/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ struct PyCodeObject _PyCode_DEF(1);
*/
#define PY_PARSER_REQUIRES_FUTURE_KEYWORD

#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
#define CO_MAXBLOCKS 21 /* Max static block nesting within a function */

PyAPI_DATA(PyTypeObject) PyCode_Type;

Expand Down
7 changes: 4 additions & 3 deletions Lib/test/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -2392,7 +2392,7 @@ def bug():
code += "): yield a"
return code

CO_MAXBLOCKS = 20 # static nesting limit of the compiler
CO_MAXBLOCKS = 21 # static nesting limit of the compiler
MAX_MANAGERS = CO_MAXBLOCKS - 1 # One for the StopIteration block

for n in range(MAX_MANAGERS):
Expand All @@ -2418,7 +2418,7 @@ async def bug():
code.append("): yield a")
return "".join(code)

CO_MAXBLOCKS = 20 # static nesting limit of the compiler
CO_MAXBLOCKS = 21 # static nesting limit of the compiler
MAX_MANAGERS = CO_MAXBLOCKS - 1 # One for the StopIteration block

for n in range(MAX_MANAGERS):
Expand Down Expand Up @@ -2563,7 +2563,8 @@ def test_syntax_error_on_deeply_nested_blocks(self):
while 20:
while 21:
while 22:
break
while 23:
break
"""
self._check_error(source, "too many statically nested blocks")

Expand Down