summaryrefslogtreecommitdiffstats
path: root/Modules/parsermodule.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-07-21 14:25:23 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-07-21 14:25:23 (GMT)
commit6a627250d2fe24ea79c5a09df58d74913586472e (patch)
tree4d08e44058834db060ed56edf9d84877269f77c7 /Modules/parsermodule.c
parent0ceb9b160335108a0235b68570b9d64df972070f (diff)
downloadcpython-6a627250d2fe24ea79c5a09df58d74913586472e.zip
cpython-6a627250d2fe24ea79c5a09df58d74913586472e.tar.gz
cpython-6a627250d2fe24ea79c5a09df58d74913586472e.tar.bz2
Merge 23c1-branch back into the head. Barry will send email about the
New Plan (releases to be made off the head, ongoing random 2.4 stuff to be done on a short-lived branch, provided anyone is motivated enough to create one).
Diffstat (limited to 'Modules/parsermodule.c')
-rw-r--r--Modules/parsermodule.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 91f15e3..4a795ed 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -106,7 +106,7 @@ node2tuple(node *n, /* node to convert */
}
(void) addelem(v, i+1, w);
}
-
+
if (TYPE(n) == encoding_decl)
(void) addelem(v, i+1, PyString_FromString(STR(n)));
return (v);
@@ -2904,11 +2904,19 @@ initparser(void)
if (parser_error == 0)
parser_error = PyErr_NewException("parser.ParserError", NULL, NULL);
- if ((parser_error == 0)
- || (PyModule_AddObject(module, "ParserError", parser_error) != 0)) {
+ 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);
Py_INCREF(&PyST_Type);