[Python-checkins] CVS: python/dist/src/Modules pyexpat.c,2.21,2.22

Fred L. Drake python-dev@python.org
Fri, 22 Sep 2000 21:55:50 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv25583/Modules

Modified Files:
	pyexpat.c 
Log Message:

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.


Index: pyexpat.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v
retrieving revision 2.21
retrieving revision 2.22
diff -C2 -r2.21 -r2.22
*** pyexpat.c	2000/09/22 15:21:31	2.21
--- pyexpat.c	2000/09/23 04:55:48	2.22
***************
*** 797,801 ****
  /* Initialization function for the module */
  
! DL_EXPORT(void) initpyexpat(void);  /* supply a prototype */
  
  DL_EXPORT(void)
--- 797,801 ----
  /* Initialization function for the module */
  
! void initpyexpat(void);  /* avoid compiler warnings */
  
  DL_EXPORT(void)
***************
*** 819,830 ****
  
      /* 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);
  
!     PyDict_SetItemString(d, "__version__",
!                          PyString_FromStringAndSize(rev+11,
!                                                     strlen(rev+11)-2));
  
      /* XXX When Expat supports some way of figuring out how it was
--- 819,829 ----
  
      /* Add some symbolic constants to the module */
      if (ErrorObject == NULL)
!         ErrorObject = PyErr_NewException("xml.parsers.expat.error",
!                                          NULL, NULL);
!     PyModule_AddObject(m, "error", ErrorObject);
  
!     PyModule_AddObject(m, "__version__",
!                        PyString_FromStringAndSize(rev+11, strlen(rev+11)-2));
  
      /* XXX When Expat supports some way of figuring out how it was
***************
*** 832,838 ****
         appropriately. 
      */
!     PyDict_SetItemString(d, "native_encoding", 
!                          PyString_FromString("UTF-8"));
  
      errors_module = PyDict_GetItem(d, errmod_name);
      if (errors_module == NULL) {
--- 831,837 ----
         appropriately. 
      */
!     PyModule_AddStringConstant(m, "native_encoding", "UTF-8");
  
+     d = PyModule_GetDict(m);
      errors_module = PyDict_GetItem(d, errmod_name);
      if (errors_module == NULL) {
***************
*** 840,845 ****
          if (errors_module != NULL) {
              sys_modules = PySys_GetObject("modules");
-             PyDict_SetItemString(d, "errors", errors_module);
              PyDict_SetItem(sys_modules, errmod_name, errors_module);
          }
      }
--- 839,845 ----
          if (errors_module != NULL) {
              sys_modules = PySys_GetObject("modules");
              PyDict_SetItem(sys_modules, errmod_name, errors_module);
+             /* gives away the reference to errors_module */
+             PyModule_AddObject(m, "errors", errors_module);
          }
      }
***************
*** 852,857 ****
  
  #define MYCONST(name) \
!     PyDict_SetItemString(errors_dict, #name,  \
! 			 PyString_FromString(XML_ErrorString(name)))
  
      MYCONST(XML_ERROR_NO_MEMORY);
--- 852,857 ----
  
  #define MYCONST(name) \
!     PyModule_AddStringConstant(errors_module, #name, \
!                                (char*)XML_ErrorString(name))
  
      MYCONST(XML_ERROR_NO_MEMORY);
***************
*** 874,877 ****
--- 874,878 ----
      MYCONST(XML_ERROR_UNKNOWN_ENCODING);
      MYCONST(XML_ERROR_INCORRECT_ENCODING);
+ #undef MYCONST
  }