[pypy-svn] r62513 - in pypy/branch/pyjitpl5/pypy: interpreter objspace/std
fijal at codespeak.net
fijal at codespeak.net
Wed Mar 4 11:16:38 CET 2009
Author: fijal
Date: Wed Mar 4 11:16:37 2009
New Revision: 62513
Modified:
pypy/branch/pyjitpl5/pypy/interpreter/pycode.py
pypy/branch/pyjitpl5/pypy/objspace/std/marshal_impl.py
Log:
make sure the consts_w is not modified after creation
Modified: pypy/branch/pyjitpl5/pypy/interpreter/pycode.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/interpreter/pycode.py (original)
+++ pypy/branch/pyjitpl5/pypy/interpreter/pycode.py Wed Mar 4 11:16:37 2009
@@ -67,8 +67,7 @@
self.co_stacksize = stacksize
self.co_flags = flags
self.co_code = code
- #self.co_consts_w = make_sure_not_modified(consts)
- self.co_consts_w = make_sure_not_resized(consts)
+ self.co_consts_w = make_sure_not_modified(consts)
self.co_names_w = [space.new_interned_str(aname) for aname in names]
self.co_varnames = varnames
self.co_freevars = freevars
@@ -138,7 +137,7 @@
code.co_stacksize,
code.co_flags,
code.co_code,
- newconsts_w,
+ newconsts_w[:],
list(code.co_names),
list(code.co_varnames),
code.co_filename,
@@ -157,9 +156,9 @@
hidden_applevel=False):
"""Initialize a new code objects from parameters given by
the pypy compiler"""
- return PyCode(space, argcount, nlocals, stacksize, flags, code, consts,
- names, varnames, filename, name, firstlineno, lnotab,
- freevars, cellvars, hidden_applevel)
+ return PyCode(space, argcount, nlocals, stacksize, flags, code,
+ consts[:], names, varnames, filename, name, firstlineno,
+ lnotab, freevars, cellvars, hidden_applevel)
_code_new_w = staticmethod(_code_new_w)
@@ -245,7 +244,7 @@
dis.dis(co)
def fget_co_consts(space, self):
- return space.newtuple(self.co_consts_w)
+ return space.newtuple(self.co_consts_w[:])
def fget_co_names(space, self):
return space.newtuple(self.co_names_w)
@@ -342,7 +341,7 @@
else:
cellvars = []
code = space.allocate_instance(PyCode, w_subtype)
- PyCode.__init__(code, space, argcount, nlocals, stacksize, flags, codestring, consts_w, names,
+ PyCode.__init__(code, space, argcount, nlocals, stacksize, flags, codestring, consts_w[:], names,
varnames, filename, name, firstlineno, lnotab, freevars, cellvars, magic=magic)
return space.wrap(code)
descr_code__new__.unwrap_spec = unwrap_spec
@@ -359,7 +358,7 @@
w(self.co_stacksize),
w(self.co_flags),
w(self.co_code),
- space.newtuple(self.co_consts_w),
+ space.newtuple(self.co_consts_w[:]),
space.newtuple(self.co_names_w),
space.newtuple([w(v) for v in self.co_varnames]),
w(self.co_filename),
Modified: pypy/branch/pyjitpl5/pypy/objspace/std/marshal_impl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/objspace/std/marshal_impl.py (original)
+++ pypy/branch/pyjitpl5/pypy/objspace/std/marshal_impl.py Wed Mar 4 11:16:37 2009
@@ -376,7 +376,7 @@
m.put_int(x.co_stacksize)
m.put_int(x.co_flags)
m.atom_str(TYPE_STRING, x.co_code)
- m.put_tuple_w(TYPE_TUPLE, x.co_consts_w)
+ m.put_tuple_w(TYPE_TUPLE, x.co_consts_w[:])
m.atom_strlist(TYPE_TUPLE, TYPE_INTERNED, [space.str_w(w_name) for w_name in x.co_names_w])
m.atom_strlist(TYPE_TUPLE, TYPE_INTERNED, x.co_varnames)
m.atom_strlist(TYPE_TUPLE, TYPE_INTERNED, x.co_freevars)
More information about the Pypy-commit
mailing list