[Python-checkins] CVS: python/dist/src/Modules pyexpat.c,2.12,2.13
Fred L. Drake
python-dev@python.org
Thu, 24 Aug 2000 14:57:46 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv6898
Modified Files:
pyexpat.c
Log Message:
Remove the Py_FatalError() from initpyexpat(); the Guido has decreed
that this is not appropriate.
Made somewhat more robust in the face of reload() (exception is not
rebuilt, etc.).
Made the exception a class exception.
Index: pyexpat.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v
retrieving revision 2.12
retrieving revision 2.13
diff -C2 -r2.12 -r2.13
*** pyexpat.c 2000/07/22 16:34:15 2.12
--- pyexpat.c 2000/08/24 21:57:43 2.13
***************
*** 864,868 ****
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
! ErrorObject = PyString_FromString("pyexpat.error");
PyDict_SetItemString(d, "error", ErrorObject);
--- 864,869 ----
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
! if (ErrorObject == NULL)
! ErrorObject = PyErr_NewException("pyexpat.error", NULL, NULL);
PyDict_SetItemString(d, "error", ErrorObject);
***************
*** 871,879 ****
strlen(rev+11)-2));
- sys_modules = PySys_GetObject("modules");
- errors_module = PyModule_New("pyexpat.errors");
- PyDict_SetItemString(d, "errors", errors_module);
- PyDict_SetItemString(sys_modules, "pyexpat.errors", errors_module);
-
/* XXX When Expat supports some way of figuring out how it was
compiled, this should check and set native_encoding
--- 872,875 ----
***************
*** 882,885 ****
--- 878,901 ----
PyDict_SetItemString(d, "native_encoding",
PyString_FromString("UTF-8"));
+
+ sys_modules = PySys_GetObject("modules");
+ {
+ PyObject *errmod_name = PyString_FromString("pyexpat.errors");
+
+ if (errmod_name != NULL) {
+ errors_module = PyDict_GetItem(errmod_name);
+ if (errors_module == NULL) {
+ errors_module = PyModule_New("pyexpat.errors");
+ if (errors_module != NULL) {
+ PyDict_SetItemString(d, "errors", errors_module);
+ PyDict_SetItem(sys_modules, errmod_name, errors_module);
+ }
+ }
+ PyDECREF(errmod_name);
+ if (errors_module == NULL)
+ /* Don't code dump later! */
+ return;
+ }
+ }
errors_dict = PyModule_GetDict(errors_module);
***************
*** 907,914 ****
MYCONST(XML_ERROR_UNKNOWN_ENCODING);
MYCONST(XML_ERROR_INCORRECT_ENCODING);
-
- /* Check for errors */
- if (PyErr_Occurred())
- Py_FatalError("can't initialize module pyexpat");
}
--- 923,926 ----