pyexpat.errors is a *strange* module!

It gets initialized when pyexpat is imported, and is only accessible as an
attribute of pyexpat; it cannot be imported itself.  This allows it to at
least be importable after pyexpat itself has been imported by adding it
to sys.modules, so it is not quite as strange.

This arrangement needs to be better thought out.
This commit is contained in:
Fred Drake 2000-07-04 23:51:31 +00:00
parent f93cb1875c
commit 7bd9f41c65
1 changed files with 15 additions and 14 deletions

View File

@ -842,6 +842,7 @@ initpyexpat(){
PyObject *m, *d;
char *rev = "$Revision$";
PyObject *errors_module, *errors_dict;
PyObject *sys_modules;
Xmlparsetype.ob_type = &PyType_Type;
@ -859,8 +860,10 @@ initpyexpat(){
PyString_FromStringAndSize(rev+11,
strlen(rev+11)-2));
errors_module=PyModule_New( "errors" );
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
@ -868,7 +871,6 @@ initpyexpat(){
*/
PyDict_SetItemString(d, "native_encoding",
PyString_FromString("UTF-8"));
errors_dict = PyModule_GetDict(errors_module);
#define MYCONST(name) \
@ -1030,4 +1032,3 @@ statichere struct HandlerInfo handler_info[]=
{NULL, NULL, NULL } /* sentinel */
};