[pypy-svn] r65949 - pypy/branch/pyjitpl5/pypy/interpreter

benjamin at codespeak.net benjamin at codespeak.net
Thu Jun 25 00:28:19 CEST 2009


Author: benjamin
Date: Thu Jun 25 00:28:19 2009
New Revision: 65949

Modified:
   pypy/branch/pyjitpl5/pypy/interpreter/pycode.py
Log:
handle PyCode sublcasses gracefully

Modified: pypy/branch/pyjitpl5/pypy/interpreter/pycode.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/interpreter/pycode.py	(original)
+++ pypy/branch/pyjitpl5/pypy/interpreter/pycode.py	Thu Jun 25 00:28:19 2009
@@ -116,7 +116,8 @@
     def signature(self):
         return self._signature
     
-    def _from_code(space, code, hidden_applevel=False):
+    @classmethod
+    def _from_code(cls, space, code, hidden_applevel=False):
         """ Initialize the code object from a real (CPython) one.
             This is just a hack, until we have our own compile.
             At the moment, we just fake this.
@@ -127,12 +128,12 @@
         num = 0
         for const in code.co_consts:
             if isinstance(const, types.CodeType): # from stable compiler
-                const = PyCode._from_code(space, const, hidden_applevel=hidden_applevel)
+                const = cls._from_code(space, const, hidden_applevel=hidden_applevel)
             newconsts_w[num] = space.wrap(const)
             num += 1
         # stick the underlying CPython magic value, if the code object
         # comes from there
-        return PyCode(space, code.co_argcount,
+        return cls(space, code.co_argcount,
                       code.co_nlocals,
                       code.co_stacksize,
                       code.co_flags,
@@ -148,8 +149,6 @@
                       list(code.co_cellvars),
                       hidden_applevel, cpython_magic)
 
-    _from_code = staticmethod(_from_code)
-
     def _code_new_w(space, argcount, nlocals, stacksize, flags,
                     code, consts, names, varnames, filename,
                     name, firstlineno, lnotab, freevars, cellvars,



More information about the Pypy-commit mailing list