Update of /cvsroot/jython/jython/org/python/core
In directory usw-pr-cvs1:/tmp/cvs-serv10361
Modified Files:
Py.java
Log Message:
exec(): Allow a file as argument to exec.
Index: Py.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v
retrieving revision 2.29
retrieving revision 2.30
diff -C2 -r2.29 -r2.30
*** Py.java 2000/12/17 15:11:27 2.29
--- Py.java 2001/01/10 11:32:10 2.30
***************
*** 1056,1064 ****
code = (PyCode)o;
else {
if (o instanceof PyString)
! code = __builtin__.compile(o.toString(), "<string>", "exec");
! else
throw Py.TypeError(
! "exec: argument 1 must be string or code object");
}
Py.runCode(code, locals, globals);
--- 1056,1071 ----
code = (PyCode)o;
else {
+ String contents = null;
if (o instanceof PyString)
! contents = o.toString();
! else if (o instanceof PyFile) {
! PyFile fp = (PyFile)o;
! if (fp.closed)
! return;
! contents = fp.read().toString();
! } else
throw Py.TypeError(
! "exec: argument 1 must be string, code or file object");
! code = __builtin__.compile(contents, "<string>", "exec");
}
Py.runCode(code, locals, globals);
|