All,
After seeing that the org.python.core.__builtin__ module behaves quite
like the cPython __builtins__ module I put together the following patch
to provide __builtins__ just like cPython.
There's a problem though... This patch was orginally application to the
nightly snapshot on 20010611. Against this snapshot everything works
fine (at least for all of the tests I've thrown at it). However, against
a more recent nightly (20010724) it fails. I've looked at it a little
and seen this:
The patch calls __builtin__.__import__ to import the __builtin__ module.
In the latest nightly this returns a null value.
In __builtin__.__import__ an early check is performed on Py.getFrame()
and a null is returned if the frame is null. This is what is happening
here. Inserting a debug line tells me that in 20010611 the frame is
*never* null when __import__ is called, but in 20010724 the frame is
null right before this problem occurs.
I'm going to try tonight's nightly to see if this is a transient
problem, but I wanted to throw this patch out there in case anyone finds
it useful...
-Randy Yarger
Web Elite
ry...@we...
diff -rw jython-20010611/org/python/core/PyModule.java
jython-20010619/org/python/core/PyModule.java
15,19d14
<
< if ( name.equals("__main__") ) {
< __dict__.__setitem__("__builtins__",
__builtin__.__import__("__builtin__") );
< } else if (! name.equals("__builtin__") ) {
< __dict__.__setitem__("__builtins__",
((PyModule)__builtin__.__import__("__builtin__")).__dict__ );
21d15
< }
|