From: <pj...@us...> - 2009-10-02 01:46:49
|
Revision: 6822 http://jython.svn.sourceforge.net/jython/?rev=6822&view=rev Author: pjenvey Date: 2009-10-02 01:46:27 +0000 (Fri, 02 Oct 2009) Log Message: ----------- allow exec of PyByteCode objects and simplify pycimport so it's not creating frames directly Modified Paths: -------------- trunk/jython/Lib/pycimport.py trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/Lib/pycimport.py =================================================================== --- trunk/jython/Lib/pycimport.py 2009-10-02 00:59:40 UTC (rev 6821) +++ trunk/jython/Lib/pycimport.py 2009-10-02 01:46:27 UTC (rev 6822) @@ -1,7 +1,6 @@ -import sys +import imp import os - -from org.python.core import imp as _imp, PyFrame as _Frame, Py as _Py +import sys from marshal import Unmarshaller __debugging__ = False @@ -16,11 +15,11 @@ return magic, mtime def __makeModule(name, code, path): - module = _imp.addModule(name) - builtins = _Py.getSystemState().builtins - frame = _Frame(code, module.__dict__, module.__dict__, builtins) + module = sys.modules.get(name) + if not module: + module = sys.modules[name] = imp.new_module(name) module.__file__ = path - code.call(frame) # execute module code + exec code in module.__dict__ return module class __Importer(object): Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-10-02 00:59:40 UTC (rev 6821) +++ trunk/jython/src/org/python/core/Py.java 2009-10-02 01:46:27 UTC (rev 6822) @@ -1178,8 +1178,7 @@ return makeException(null); } - public static PyObject runCode(PyCode code, PyObject locals, - PyObject globals) { + public static PyObject runCode(PyCode code, PyObject locals, PyObject globals) { PyFrame f; ThreadState ts = getThreadState(); if (locals == null || locals == Py.None) { @@ -1194,13 +1193,12 @@ globals = ts.frame.f_globals; } - PyTableCode tc = null; - if (code instanceof PyTableCode) { - tc = (PyTableCode) code; + PyBaseCode baseCode = null; + if (code instanceof PyBaseCode) { + baseCode = (PyBaseCode) code; } - f = new PyFrame(tc, locals, globals, - Py.getSystemState().getBuiltins()); + f = new PyFrame(baseCode, locals, globals, Py.getSystemState().getBuiltins()); return code.call(ts, f); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |