diff options
author | Fred Drake <fdrake@acm.org> | 2000-09-23 04:55:48 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2000-09-23 04:55:48 (GMT) |
commit | 93adb6918ce86efbb19620d88a7d2acb18427b37 (patch) | |
tree | ddb22ee078b7697882d4ebd11779178500b6536d /Modules/pyexpat.c | |
parent | 96ea196ea895ff9922338663a2967ae747fd205a (diff) | |
download | cpython-93adb6918ce86efbb19620d88a7d2acb18427b37.zip cpython-93adb6918ce86efbb19620d88a7d2acb18427b37.tar.gz cpython-93adb6918ce86efbb19620d88a7d2acb18427b37.tar.bz2 |
Change the name of the exception from "pyexpat.error" to
"xml.parsers.expat.error", so it will reflect the public name of the
exception rather than the internal name.
Also change some of the initialization to use the new PyModule_Add*()
convenience functions.
Diffstat (limited to 'Modules/pyexpat.c')
-rw-r--r-- | Modules/pyexpat.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index ce66e5a..28ad8e8 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -796,7 +796,7 @@ static char pyexpat_module_documentation[] = /* Initialization function for the module */ -DL_EXPORT(void) initpyexpat(void); /* supply a prototype */ +void initpyexpat(void); /* avoid compiler warnings */ DL_EXPORT(void) initpyexpat(void) @@ -818,29 +818,29 @@ initpyexpat(void) (PyObject*)NULL, PYTHON_API_VERSION); /* 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); + ErrorObject = PyErr_NewException("xml.parsers.expat.error", + NULL, NULL); + PyModule_AddObject(m, "error", ErrorObject); - PyDict_SetItemString(d, "__version__", - PyString_FromStringAndSize(rev+11, - strlen(rev+11)-2)); + PyModule_AddObject(m, "__version__", + PyString_FromStringAndSize(rev+11, strlen(rev+11)-2)); /* XXX When Expat supports some way of figuring out how it was compiled, this should check and set native_encoding appropriately. */ - PyDict_SetItemString(d, "native_encoding", - PyString_FromString("UTF-8")); + PyModule_AddStringConstant(m, "native_encoding", "UTF-8"); + d = PyModule_GetDict(m); errors_module = PyDict_GetItem(d, errmod_name); if (errors_module == NULL) { errors_module = PyModule_New("pyexpat.errors"); if (errors_module != NULL) { sys_modules = PySys_GetObject("modules"); - PyDict_SetItemString(d, "errors", errors_module); PyDict_SetItem(sys_modules, errmod_name, errors_module); + /* gives away the reference to errors_module */ + PyModule_AddObject(m, "errors", errors_module); } } Py_DECREF(errmod_name); @@ -851,8 +851,8 @@ initpyexpat(void) errors_dict = PyModule_GetDict(errors_module); #define MYCONST(name) \ - PyDict_SetItemString(errors_dict, #name, \ - PyString_FromString(XML_ErrorString(name))) + PyModule_AddStringConstant(errors_module, #name, \ + (char*)XML_ErrorString(name)) MYCONST(XML_ERROR_NO_MEMORY); MYCONST(XML_ERROR_SYNTAX); @@ -873,6 +873,7 @@ initpyexpat(void) MYCONST(XML_ERROR_MISPLACED_XML_PI); MYCONST(XML_ERROR_UNKNOWN_ENCODING); MYCONST(XML_ERROR_INCORRECT_ENCODING); +#undef MYCONST } static void |