summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-08-25 17:19:38 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-08-25 17:19:38 (GMT)
commit1792bfbf902c5850889ced14403b89b8f895724e (patch)
tree3ea80063266fbf8678429dafabe8a009bdbbccea /Python/compile.c
parent65d3c0537a061f392db260a13d2a6d239593c2eb (diff)
downloadcpython-1792bfbf902c5850889ced14403b89b8f895724e.zip
cpython-1792bfbf902c5850889ced14403b89b8f895724e.tar.gz
cpython-1792bfbf902c5850889ced14403b89b8f895724e.tar.bz2
Bypass peepholing of code with lineno tables having intervals >= 255.
Allows the lineno fixup code to remain simple and not have to deal with multibyte codings. * Add an assertion to that effect. * Remove the XXX comment on the subject.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 1de249f..4653ff7 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -435,6 +435,13 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
unsigned int *blocks;
char *name;
+ /* Bypass optimization when the lineno table is too complex */
+ assert(PyString_Check(lineno_obj));
+ lineno = PyString_AS_STRING(lineno_obj);
+ tabsiz = PyString_GET_SIZE(lineno_obj);
+ if (memchr(lineno, 255, tabsiz) != NULL)
+ goto exitUnchanged;
+
if (!PyString_Check(code))
goto exitUnchanged;
@@ -614,15 +621,12 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
}
/* Fixup linenotab */
- /* XXX make sure this handles intervals > 256 */
- assert(PyString_Check(lineno_obj));
- lineno = PyString_AS_STRING(lineno_obj);
- tabsiz = PyString_GET_SIZE(lineno_obj);
cum_orig_line = 0;
last_line = 0;
for (i=0 ; i < tabsiz ; i+=2) {
cum_orig_line += lineno[i];
new_line = addrmap[cum_orig_line];
+ assert (new_line - last_line < 255);
lineno[i] =((unsigned char)(new_line - last_line));
last_line = new_line;
}