[Python-checkins] cpython (3.3): Issue #17645: convert an assert() into a proper exception in _Py_Mangle().

antoine.pitrou python-checkins at python.org
Sat Apr 6 21:24:39 CEST 2013


http://hg.python.org/cpython/rev/72f0fd0c4d90
changeset:   83160:72f0fd0c4d90
branch:      3.3
parent:      83153:aaaf36026511
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sat Apr 06 21:21:04 2013 +0200
summary:
  Issue #17645: convert an assert() into a proper exception in _Py_Mangle().

files:
  Python/compile.c |  7 +++++--
  1 files changed, 5 insertions(+), 2 deletions(-)


diff --git a/Python/compile.c b/Python/compile.c
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -248,8 +248,11 @@
     }
     plen -= ipriv;
 
-    assert(1 <= PY_SSIZE_T_MAX - nlen);
-    assert(1 + nlen <= PY_SSIZE_T_MAX - plen);
+    if (plen + nlen >= PY_SSIZE_T_MAX - 1) {
+        PyErr_SetString(PyExc_OverflowError,
+                        "private identifier too large to be mangled");
+        return NULL;
+    }
 
     maxchar = PyUnicode_MAX_CHAR_VALUE(ident);
     if (PyUnicode_MAX_CHAR_VALUE(privateobj) > maxchar)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list