Update of /cvsroot/jython/jython/org/python/core
In directory slayer.i.sourceforge.net:/tmp/cvs-serv30862
Modified Files:
__builtin__.java
Log Message:
__import__(): Added 4 argument __import__ API. Calling these methods
will call the __import__ hook function.
Index: __builtin__.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/core/__builtin__.java,v
retrieving revision 2.21
retrieving revision 2.22
diff -C2 -r2.21 -r2.22
*** __builtin__.java 2000/10/09 14:45:14 2.21
--- __builtin__.java 2000/12/11 18:43:15 2.22
***************
*** 886,893 ****
}
! public static synchronized PyObject __import__(PyString name) {
! return imp.importName(name.internedString(), true);
}
private static PyObject[] make_array(PyObject o) {
if (o instanceof PyTuple)
--- 886,925 ----
}
! public static PyObject __import__(String name) {
! return __import__(name, null, null, null);
}
+ public static PyObject __import__(String name, PyObject globals) {
+ return __import__(name, globals, null, null);
+ }
+
+ public static PyObject __import__(String name, PyObject globals,
+ PyObject locals) {
+ return __import__(name, globals, locals, null);
+ }
+
+ public static PyObject __import__(String name, PyObject globals,
+ PyObject locals,PyObject fromlist)
+ {
+ PyFrame frame = Py.getFrame();
+ if (frame == null)
+ return null;
+
+ PyObject builtins = frame.f_builtins;
+ if (builtins == null)
+ builtins = Py.getSystemState().builtins;
+
+ PyObject __import__ = builtins.__finditem__("__import__");
+ if (__import__ == null)
+ return null;
+
+ PyObject module = __import__.__call__(new PyObject[] {
+ Py.newString(name),
+ globals,
+ locals,
+ fromlist } );
+ return module;
+ }
+
private static PyObject[] make_array(PyObject o) {
if (o instanceof PyTuple)
***************
*** 920,924 ****
? args[2] : __builtin__.locals();
PyObject fromlist = (argc > 3 && args[3] != null)
! ? args[3] : new PyList();
return load(module, globals, locals, fromlist);
--- 952,956 ----
? args[2] : __builtin__.locals();
PyObject fromlist = (argc > 3 && args[3] != null)
! ? args[3] : Py.EmptyTuple;
return load(module, globals, locals, fromlist);
|