import os
import random
import sys
+import py_compile
# Brief digression to test that import is case-sensitive: if we got this
# far, we know for sure that "random" exists.
import imp
x = imp.find_module("os")
os = imp.load_module("os", *x)
+
+def test_module_with_large_stack(module):
+ # create module w/list of 65000 elements to test bug #561858
+ filename = module + '.py'
+
+ # create a file with a list of 65000 elements
+ f = open(filename, 'w+')
+ f.write('d = [\n')
+ for i in range(65000):
+ f.write('"",\n')
+ f.write(']')
+ f.close()
+
+ # compile & remove .py file, we only need .pyc
+ f = open(filename, 'r')
+ py_compile.compile(filename)
+ os.unlink(filename)
+
+ # need to be able to load from current dir
+ sys.path.append('')
+
+ # this used to crash
+ exec 'import ' + module
+
+ # cleanup
+ del sys.path[-1]
+ os.unlink(module + '.pyc')
+
+test_module_with_large_stack('longlist')
+
else if (PyCode_Check(v)) {
PyCodeObject *co = (PyCodeObject *)v;
w_byte(TYPE_CODE, p);
- w_short(co->co_argcount, p);
- w_short(co->co_nlocals, p);
- w_short(co->co_stacksize, p);
- w_short(co->co_flags, p);
+ w_long(co->co_argcount, p);
+ w_long(co->co_nlocals, p);
+ w_long(co->co_stacksize, p);
+ w_long(co->co_flags, p);
w_object(co->co_code, p);
w_object(co->co_consts, p);
w_object(co->co_names, p);
w_object(co->co_cellvars, p);
w_object(co->co_filename, p);
w_object(co->co_name, p);
- w_short(co->co_firstlineno, p);
+ w_long(co->co_firstlineno, p);
w_object(co->co_lnotab, p);
}
else if (PyObject_CheckReadBuffer(v)) {
return NULL;
}
else {
- int argcount = r_short(p);
- int nlocals = r_short(p);
- int stacksize = r_short(p);
- int flags = r_short(p);
+ int argcount = r_long(p);
+ int nlocals = r_long(p);
+ int stacksize = r_long(p);
+ int flags = r_long(p);
PyObject *code = NULL;
PyObject *consts = NULL;
PyObject *names = NULL;
if (cellvars) filename = r_object(p);
if (filename) name = r_object(p);
if (name) {
- firstlineno = r_short(p);
+ firstlineno = r_long(p);
lnotab = r_object(p);
}