[Python-checkins] CVS: python/dist/src/Modules parsermodule.c,2.64,2.65

Fred L. Drake fdrake@users.sourceforge.net
Wed, 15 Aug 2001 09:44:58 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv18771

Modified Files:
	parsermodule.c 
Log Message:

Use the abstract object interfaces when digging around in module objects
instead of directly manipulating the underlying dictionary.


Index: parsermodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/parsermodule.c,v
retrieving revision 2.64
retrieving revision 2.65
diff -C2 -d -r2.64 -r2.65
*** parsermodule.c	2001/07/19 20:17:15	2.64
--- parsermodule.c	2001/08/15 16:44:56	2.65
***************
*** 2817,2821 ****
  
      /* private stuff: support pickle module */
!     {"_pickler",        (PyCFunction)parser__pickler,   METH_VARARGS,
          "Returns the pickle magic to allow ST objects to be pickled."},
  
--- 2817,2821 ----
  
      /* private stuff: support pickle module */
!     {"_pickler",        (PyCFunction)parser__pickler,  METH_VARARGS,
          "Returns the pickle magic to allow ST objects to be pickled."},
  
***************
*** 2829,2838 ****
  initparser(void)
  {
!     PyObject* module;
!     PyObject* dict;
  
      PyST_Type.ob_type = &PyType_Type;
      module = Py_InitModule("parser", parser_functions);
-     dict = PyModule_GetDict(module);
  
      if (parser_error == 0)
--- 2829,2836 ----
  initparser(void)
  {
!     PyObject *module, *copyreg;
  
      PyST_Type.ob_type = &PyType_Type;
      module = Py_InitModule("parser", parser_functions);
  
      if (parser_error == 0)
***************
*** 2840,2858 ****
  
      if ((parser_error == 0)
!         || (PyDict_SetItemString(dict, "ParserError", parser_error) != 0)) {
          /* caller will check PyErr_Occurred() */
          return;
      }
      Py_INCREF(&PyST_Type);
!     PyDict_SetItemString(dict, "ASTType", (PyObject*)&PyST_Type);
      Py_INCREF(&PyST_Type);
!     PyDict_SetItemString(dict, "STType", (PyObject*)&PyST_Type);
  
!     PyDict_SetItemString(dict, "__copyright__",
!                          PyString_FromString(parser_copyright_string));
!     PyDict_SetItemString(dict, "__doc__",
!                          PyString_FromString(parser_doc_string));
!     PyDict_SetItemString(dict, "__version__",
!                          PyString_FromString(parser_version_string));
  
      /* Register to support pickling.
--- 2838,2856 ----
  
      if ((parser_error == 0)
!         || (PyModule_AddObject(module, "ParserError", parser_error) != 0)) {
          /* caller will check PyErr_Occurred() */
          return;
      }
      Py_INCREF(&PyST_Type);
!     PyModule_AddObject(module, "ASTType", (PyObject*)&PyST_Type);
      Py_INCREF(&PyST_Type);
!     PyModule_AddObject(module, "STType", (PyObject*)&PyST_Type);
  
!     PyModule_AddStringConstant(module, "__copyright__",
!                                parser_copyright_string);
!     PyModule_AddStringConstant(module, "__doc__",
!                                parser_doc_string);
!     PyModule_AddStringConstant(module, "__version__",
!                                parser_version_string);
  
      /* Register to support pickling.
***************
*** 2860,2870 ****
       * exception will be raised here; should we clear the exception?
       */
!     module = PyImport_ImportModule("copy_reg");
!     if (module != NULL) {
          PyObject *func, *pickler;
  
!         func = PyObject_GetAttrString(module, "pickle");
!         pickle_constructor = PyDict_GetItemString(dict, "sequence2st");
!         pickler = PyDict_GetItemString(dict, "_pickler");
          Py_XINCREF(pickle_constructor);
          if ((func != NULL) && (pickle_constructor != NULL)
--- 2858,2868 ----
       * exception will be raised here; should we clear the exception?
       */
!     copyreg = PyImport_ImportModule("copy_reg");
!     if (copyreg != NULL) {
          PyObject *func, *pickler;
  
!         func = PyObject_GetAttrString(copyreg, "pickle");
!         pickle_constructor = PyObject_GetAttrString(module, "sequence2st");
!         pickler = PyObject_GetAttrString(module, "_pickler");
          Py_XINCREF(pickle_constructor);
          if ((func != NULL) && (pickle_constructor != NULL)
***************
*** 2877,2881 ****
          }
          Py_XDECREF(func);
!         Py_DECREF(module);
      }
  }
--- 2875,2881 ----
          }
          Py_XDECREF(func);
!         Py_XDECREF(pickle_constructor);
!         Py_XDECREF(pickler);
!         Py_DECREF(copyreg);
      }
  }