[Python-checkins] cpython (3.5): make too many nested blocks be a SyntaxError instead of a SystemError (closes
benjamin.peterson
python-checkins at python.org
Fri Jul 15 01:02:18 EDT 2016
https://hg.python.org/cpython/rev/e6e7c8368c70
changeset: 102350:e6e7c8368c70
branch: 3.5
parent: 102348:270fd4493195
user: Benjamin Peterson <benjamin at python.org>
date: Thu Jul 14 22:00:03 2016 -0700
summary:
make too many nested blocks be a SyntaxError instead of a SystemError (closes #27514)
Patch by Ammar Askar.
files:
Lib/test/test_syntax.py | 6 ++++--
Misc/NEWS | 3 +++
Python/compile.c | 2 +-
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -342,7 +342,9 @@
...
SyntaxError: 'break' outside loop
-This should probably raise a better error than a SystemError (or none at all).
+This raises a SyntaxError, it used to raise a SystemError.
+Context for this change can be found on issue #27514
+
In 2.5 there was a missing exception and an assert was triggered in a debug
build. The number of blocks must be greater than CO_MAXBLOCKS. SF #1565514
@@ -370,7 +372,7 @@
... break
Traceback (most recent call last):
...
- SystemError: too many statically nested blocks
+ SyntaxError: too many statically nested blocks
Misuse of the nonlocal statement can lead to a few unique syntax errors.
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #27514: Make having too many statically nested blocks a SyntaxError
+ instead of SystemError.
+
- Issue #27473: Fixed possible integer overflow in bytes and bytearray
concatenations. Patch by Xiang Zhang.
diff --git a/Python/compile.c b/Python/compile.c
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -3980,7 +3980,7 @@
{
struct fblockinfo *f;
if (c->u->u_nfblocks >= CO_MAXBLOCKS) {
- PyErr_SetString(PyExc_SystemError,
+ PyErr_SetString(PyExc_SyntaxError,
"too many statically nested blocks");
return 0;
}
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list