? test.py ? test2.py ? test3.py ? Modules/+heapqmodule.c ? Python/ceval.c.386 Index: Include/pyerrors.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pyerrors.h,v retrieving revision 2.65 diff -c -r2.65 pyerrors.h *** Include/pyerrors.h 1 Jul 2003 20:15:21 -0000 2.65 --- Include/pyerrors.h 16 Aug 2004 11:03:54 -0000 *************** *** 26,31 **** --- 26,32 ---- PyAPI_DATA(PyObject *) PyExc_Exception; PyAPI_DATA(PyObject *) PyExc_StopIteration; PyAPI_DATA(PyObject *) PyExc_StandardError; + PyAPI_DATA(PyObject *) PyExc_AsynchronousException; PyAPI_DATA(PyObject *) PyExc_ArithmeticError; PyAPI_DATA(PyObject *) PyExc_LookupError; Index: Include/pystate.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/pystate.h,v retrieving revision 2.29 diff -c -r2.29 pystate.h *** Include/pystate.h 8 Jun 2004 08:17:42 -0000 2.29 --- Include/pystate.h 16 Aug 2004 11:03:54 -0000 *************** *** 88,93 **** --- 88,95 ---- int gilstate_counter; PyObject *async_exc; /* Asynchronous exception to raise */ + PyObject *async_exc_value; + PyObject *async_exc_traceback; long thread_id; /* Thread id where this tstate was created */ /* XXX signal handlers should also be here */ Index: Python/ceval.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v retrieving revision 2.415 diff -c -r2.415 ceval.c *** Python/ceval.c 12 Aug 2004 18:19:07 -0000 2.415 --- Python/ceval.c 16 Aug 2004 11:04:13 -0000 *************** *** 795,813 **** PyThread_acquire_lock(interpreter_lock, 1); if (PyThreadState_Swap(tstate) != NULL) Py_FatalError("ceval: orphan tstate"); - - /* Check for thread interrupts */ - - if (tstate->async_exc != NULL) { - x = tstate->async_exc; - tstate->async_exc = NULL; - PyErr_SetNone(x); - Py_DECREF(x); - why = WHY_EXCEPTION; - goto on_error; - } } #endif } fast_next_opcode: --- 795,814 ---- PyThread_acquire_lock(interpreter_lock, 1); if (PyThreadState_Swap(tstate) != NULL) Py_FatalError("ceval: orphan tstate"); } #endif + /* Check for asynchronous exceptions */ + if (tstate->async_exc != NULL) { + u = tstate->async_exc; + v = tstate->async_exc_value; + w = tstate->async_exc_traceback; + tstate->async_exc = NULL; + tstate->async_exc_value = NULL; + tstate->async_exc_traceback = NULL; + PyErr_Restore(u, v, w); + why = WHY_EXCEPTION; + goto on_error; + } } fast_next_opcode: Index: Python/errors.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/errors.c,v retrieving revision 2.82 diff -c -r2.82 errors.c *** Python/errors.c 24 Mar 2004 22:22:11 -0000 2.82 --- Python/errors.c 16 Aug 2004 11:04:14 -0000 *************** *** 219,224 **** --- 219,237 ---- void PyErr_Clear(void) { + if (PyErr_ExceptionMatches(PyExc_AsynchronousException)) { + /* save the first asynchronous exception -- + it will be restored by ceval.c */ + PyThreadState *tstate = PyThreadState_GET(); + if (tstate->async_exc == NULL && + tstate->async_exc_value == NULL && + tstate->async_exc_traceback == NULL) { + PyErr_Fetch(&tstate->async_exc, + &tstate->async_exc_value, + &tstate->async_exc_traceback); + _Py_Ticker = 0; /* signal the main loop in ceval.c */ + } + } PyErr_Restore(NULL, NULL, NULL); } Index: Python/exceptions.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v retrieving revision 1.48 diff -c -r1.48 exceptions.c *** Python/exceptions.c 12 Oct 2003 19:09:37 -0000 1.48 --- Python/exceptions.c 16 Aug 2004 11:04:14 -0000 *************** *** 59,65 **** +-- StopIteration\n\ +-- StandardError\n\ | |\n\ - | +-- KeyboardInterrupt\n\ | +-- ImportError\n\ | +-- EnvironmentError\n\ | | |\n\ --- 59,64 ---- *************** *** 70,79 **** | | +-- VMSError\n\ | |\n\ | +-- EOFError\n\ ! | +-- RuntimeError\n\ ! | | |\n\ ! | | +-- NotImplementedError\n\ ! | |\n\ | +-- NameError\n\ | | |\n\ | | +-- UnboundLocalError\n\ --- 69,75 ---- | | +-- VMSError\n\ | |\n\ | +-- EOFError\n\ ! | +-- NotImplementedError\n\ | +-- NameError\n\ | | |\n\ | | +-- UnboundLocalError\n\ *************** *** 108,113 **** --- 104,114 ---- | |\n\ | +-- ReferenceError\n\ | +-- SystemError\n\ + |\n\ + +-- AsynchronousException\n\ + | |\n\ + | +-- KeyboardInterrupt\n\ + | +-- RuntimeError\n\ | +-- MemoryError\n\ |\n\ +---Warning\n\ *************** *** 395,400 **** --- 396,404 ---- PyDoc_STRVAR(StopIteration__doc__, "Signal the end from iterator.next()."); + PyDoc_STRVAR(AsynchronousException__doc__, + "Base class for exceptions signalling program-independant errors."); + PyDoc_STRVAR(SystemExit__doc__, "Request to exit from the interpreter."); *************** *** 1584,1589 **** --- 1588,1594 ---- PyObject *PyExc_Exception; PyObject *PyExc_StopIteration; PyObject *PyExc_StandardError; + PyObject *PyExc_AsynchronousException; PyObject *PyExc_ArithmeticError; PyObject *PyExc_LookupError; *************** *** 1662,1670 **** /* * The rest appear in depth-first order of the hierarchy */ {"SystemExit", &PyExc_SystemExit, &PyExc_Exception, SystemExit__doc__, SystemExit_methods}, ! {"KeyboardInterrupt", &PyExc_KeyboardInterrupt, 0, KeyboardInterrupt__doc__}, {"ImportError", &PyExc_ImportError, 0, ImportError__doc__}, {"EnvironmentError", &PyExc_EnvironmentError, 0, EnvironmentError__doc__, EnvironmentError_methods}, --- 1667,1678 ---- /* * The rest appear in depth-first order of the hierarchy */ + {"AsynchronousException", &PyExc_AsynchronousException, &PyExc_Exception, + AsynchronousException__doc__}, {"SystemExit", &PyExc_SystemExit, &PyExc_Exception, SystemExit__doc__, SystemExit_methods}, ! {"KeyboardInterrupt", &PyExc_KeyboardInterrupt, ! &PyExc_AsynchronousException, KeyboardInterrupt__doc__}, {"ImportError", &PyExc_ImportError, 0, ImportError__doc__}, {"EnvironmentError", &PyExc_EnvironmentError, 0, EnvironmentError__doc__, EnvironmentError_methods}, *************** *** 1679,1687 **** VMSError__doc__}, #endif {"EOFError", &PyExc_EOFError, 0, EOFError__doc__}, ! {"RuntimeError", &PyExc_RuntimeError, 0, RuntimeError__doc__}, ! {"NotImplementedError", &PyExc_NotImplementedError, ! &PyExc_RuntimeError, NotImplementedError__doc__}, {"NameError", &PyExc_NameError, 0, NameError__doc__}, {"UnboundLocalError", &PyExc_UnboundLocalError, &PyExc_NameError, UnboundLocalError__doc__}, --- 1687,1696 ---- VMSError__doc__}, #endif {"EOFError", &PyExc_EOFError, 0, EOFError__doc__}, ! {"RuntimeError", &PyExc_RuntimeError, &PyExc_AsynchronousException, ! RuntimeError__doc__}, ! {"NotImplementedError", &PyExc_NotImplementedError, 0, ! NotImplementedError__doc__}, {"NameError", &PyExc_NameError, 0, NameError__doc__}, {"UnboundLocalError", &PyExc_UnboundLocalError, &PyExc_NameError, UnboundLocalError__doc__}, *************** *** 1717,1723 **** #endif {"ReferenceError", &PyExc_ReferenceError, 0, ReferenceError__doc__}, {"SystemError", &PyExc_SystemError, 0, SystemError__doc__}, ! {"MemoryError", &PyExc_MemoryError, 0, MemoryError__doc__}, /* Warning categories */ {"Warning", &PyExc_Warning, &PyExc_Exception, Warning__doc__}, {"UserWarning", &PyExc_UserWarning, &PyExc_Warning, UserWarning__doc__}, --- 1726,1733 ---- #endif {"ReferenceError", &PyExc_ReferenceError, 0, ReferenceError__doc__}, {"SystemError", &PyExc_SystemError, 0, SystemError__doc__}, ! {"MemoryError", &PyExc_MemoryError, &PyExc_AsynchronousException, ! MemoryError__doc__}, /* Warning categories */ {"Warning", &PyExc_Warning, &PyExc_Exception, Warning__doc__}, {"UserWarning", &PyExc_UserWarning, &PyExc_Warning, UserWarning__doc__}, Index: Python/pystate.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pystate.c,v retrieving revision 2.31 diff -c -r2.31 pystate.c *** Python/pystate.c 8 Jun 2004 08:17:44 -0000 2.31 --- Python/pystate.c 16 Aug 2004 11:04:14 -0000 *************** *** 147,152 **** --- 147,154 ---- tstate->tick_counter = 0; tstate->gilstate_counter = 0; tstate->async_exc = NULL; + tstate->async_exc_value = NULL; + tstate->async_exc_traceback = NULL; #ifdef WITH_THREAD tstate->thread_id = PyThread_get_thread_ident(); #else *************** *** 189,194 **** --- 191,198 ---- ZAP(tstate->dict); ZAP(tstate->async_exc); + ZAP(tstate->async_exc_value); + ZAP(tstate->async_exc_traceback); ZAP(tstate->curexc_type); ZAP(tstate->curexc_value); *************** *** 324,329 **** --- 328,335 ---- if (p->thread_id != id) continue; ZAP(p->async_exc); + ZAP(p->async_exc_value); + ZAP(p->async_exc_traceback); Py_XINCREF(exc); p->async_exc = exc; count += 1;