Update of /cvsroot/jython/jython/org/python/core
In directory usw-pr-cvs1:/tmp/cvs-serv26183/core
Modified Files:
Py.java PySystemState.java
Log Message:
Fix for "[ #476772 ] shutdowns in jython / atexit"
Call sys.exitfunc when the interpreter is about to exit.
Index: Py.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v
retrieving revision 2.51
retrieving revision 2.52
diff -C2 -d -r2.51 -r2.52
*** Py.java 2001/10/28 17:13:42 2.51
--- Py.java 2001/11/03 19:26:02 2.52
***************
*** 160,163 ****
--- 160,164 ----
value = tmp;
}
+ Py.getSystemState().callExitFunc();
if (value instanceof PyInteger) {
System.exit(((PyInteger)value).getValue());
***************
*** 823,828 ****
--- 824,831 ----
} catch (PyException e) {
Py.printException(e);
+ Py.getSystemState().callExitFunc();
System.exit(-1);
}
+ Py.getSystemState().callExitFunc();
}
Index: PySystemState.java
===================================================================
RCS file: /cvsroot/jython/jython/org/python/core/PySystemState.java,v
retrieving revision 2.63
retrieving revision 2.64
diff -C2 -d -r2.63 -r2.64
*** PySystemState.java 2001/10/28 17:13:43 2.63
--- PySystemState.java 2001/11/03 19:26:02 2.64
***************
*** 629,632 ****
--- 629,646 ----
sys.builtins.__setitem__("_", o);
}
+
+ public void callExitFunc() throws PyIgnoreMethodTag {
+ PyObject exitfunc = __findattr__("exitfunc");
+ if (exitfunc != null) {
+ try {
+ exitfunc.__call__();
+ } catch (PyException exc) {
+ if (!Py.matchException(exc, Py.SystemExit)) {
+ Py.println(stderr, Py.newString("Error in sys.exitfunc:"));
+ }
+ Py.printException(exc);
+ }
+ }
+ }
}
|