[Python-checkins] python/dist/src/Modules parsermodule.c,2.79,2.79.6.1

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sat, 19 Jul 2003 14:44:34 -0700


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

Modified Files:
      Tag: r23c1-branch
	parsermodule.c 
Log Message:
The parser module's initialization left the refcount on parser_error
too small.  Fixed.

Fiddled NEWS to reflect my belief that we're going to need an r23c2
release.


Index: parsermodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/parsermodule.c,v
retrieving revision 2.79
retrieving revision 2.79.6.1
diff -C2 -d -r2.79 -r2.79.6.1
*** parsermodule.c	9 Apr 2003 17:53:22 -0000	2.79
--- parsermodule.c	19 Jul 2003 21:44:32 -0000	2.79.6.1
***************
*** 107,111 ****
              (void) addelem(v, i+1, w);
          }
! 	
          if (TYPE(n) == encoding_decl)
              (void) addelem(v, i+1, PyString_FromString(STR(n)));
--- 107,111 ----
              (void) addelem(v, i+1, w);
          }
! 
          if (TYPE(n) == encoding_decl)
              (void) addelem(v, i+1, PyString_FromString(STR(n)));
***************
*** 2905,2913 ****
          parser_error = PyErr_NewException("parser.ParserError", NULL, NULL);
  
!     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);
--- 2905,2921 ----
          parser_error = PyErr_NewException("parser.ParserError", NULL, NULL);
  
!     if (parser_error == 0)
          /* caller will check PyErr_Occurred() */
          return;
!     /* CAUTION:  The code next used to skip bumping the refcount on
!      * parser_error.  That's a disaster if initparser() gets called more
!      * than once.  By incref'ing, we ensure that each module dict that
!      * gets created owns its reference to the shared parser_error object,
!      * and the file static parser_error vrbl owns a reference too.
!      */
!     Py_INCREF(parser_error);
!     if (PyModule_AddObject(module, "ParserError", parser_error) != 0)
!         return;
! 
      Py_INCREF(&PyST_Type);
      PyModule_AddObject(module, "ASTType", (PyObject*)&PyST_Type);