Index: Python/exceptions.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v retrieving revision 1.49 diff -c -b -B -r1.49 exceptions.c *** Python/exceptions.c 25 Aug 2004 02:14:08 -0000 1.49 --- Python/exceptions.c 1 Oct 2004 05:37:42 -0000 *************** *** 53,58 **** --- 53,62 ---- `Exception' class, although this is currently not enforced.\n" /* keep string pieces "small" */ "\n\ + The \'special_exceptions\' tuple lists those exceptions which the majority\n\ + of user code should avoid suppressing. Exceptions in this list should\n\ + generally be propagated to the main interpreter loop to be dealt with.\n" + "\n\ Exception\n\ |\n\ +-- SystemExit\n\ *************** *** 1738,1744 **** {NULL} }; ! void _PyExc_Init(void) --- 1742,1757 ---- {NULL} }; ! /* The "special" exceptions */ ! static PyObject **special_exceptions[] = ! { ! &PyExc_SystemExit, ! &PyExc_MemoryError, ! &PyExc_KeyboardInterrupt, ! &PyExc_StopIteration, ! /* Sentinel */ ! NULL ! }; void _PyExc_Init(void) *************** *** 1746,1752 **** char *modulename = "exceptions"; int modnamesz = strlen(modulename); int i; ! PyObject *me, *mydict, *bltinmod, *bdict, *doc, *args; me = Py_InitModule(modulename, functions); if (me == NULL) --- 1759,1765 ---- char *modulename = "exceptions"; int modnamesz = strlen(modulename); int i; ! PyObject *me, *mydict, *bltinmod, *bdict, *doc, *args, *spec, *exc; me = Py_InitModule(modulename, functions); if (me == NULL) *************** *** 1831,1836 **** --- 1844,1875 ---- } Py_DECREF(args); + /* Create a tuple to contain the "special" exceptions */ + i = 0; + while (special_exceptions[i]) { + ++i; + } + spec = PyTuple_New(i); + if (!spec) + { + Py_FatalError("Cannot create special exceptions tuple\n"); + } + i = 0; + while (special_exceptions[i]) { + exc = *special_exceptions[i]; + Py_INCREF(exc); + if (PyTuple_SetItem(spec, i, exc)) { + Py_FatalError("Problem populating special exceptions tuple\n"); + } + ++i; + } + if (PyDict_SetItemString(mydict, "special_exceptions", spec) || + PyDict_SetItemString(bdict, "special_exceptions", spec)) + { + Py_FatalError("Module dictionary insertion problem."); + } + Py_DECREF(spec); + /* We're done with __builtin__ */ Py_DECREF(bltinmod); }