[Python-checkins] r62819 - in python/branches/tlee-ast-optimize: Parser/asdl_c.py Python/Python-ast.c
thomas.lee
python-checkins at python.org
Wed May 7 14:32:20 CEST 2008
Author: thomas.lee
Date: Wed May 7 14:32:20 2008
New Revision: 62819
Log:
Added special handling of the Const() constructor value.
Modified:
python/branches/tlee-ast-optimize/Parser/asdl_c.py
python/branches/tlee-ast-optimize/Python/Python-ast.c
Modified: python/branches/tlee-ast-optimize/Parser/asdl_c.py
==============================================================================
--- python/branches/tlee-ast-optimize/Parser/asdl_c.py (original)
+++ python/branches/tlee-ast-optimize/Parser/asdl_c.py Wed May 7 14:32:20 2008
@@ -292,8 +292,14 @@
emit("{")
emit("%s p;" % ctype, 1)
for argtype, argname, opt in args:
+ # XXX: Const() hack to force Py_None if NULL given to ctor
+ if str(argname) == 'value' and str(name) == 'Const':
+ emit("if (!%s) {" % argname, 1)
+ emit("Py_INCREF(Py_None);", 2)
+ emit("%s = Py_None;" % argname, 2)
+ emit("}", 1)
# XXX hack alert: false is allowed for a bool
- if not opt and not (argtype == "bool" or argtype == "int"):
+ elif not opt and not (argtype == "bool" or argtype == "int"):
emit("if (!%s) {" % argname, 1)
emit("PyErr_SetString(PyExc_ValueError,", 2)
msg = "field %s is required for %s" % (argname, name)
Modified: python/branches/tlee-ast-optimize/Python/Python-ast.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/Python-ast.c (original)
+++ python/branches/tlee-ast-optimize/Python/Python-ast.c Wed May 7 14:32:20 2008
@@ -2,7 +2,7 @@
/*
- __version__ 62047.
+ __version__ 62816.
This module must be committed separately after each AST grammar change;
The __version__ number is set to the revision number of the commit
@@ -1746,9 +1746,8 @@
{
expr_ty p;
if (!value) {
- PyErr_SetString(PyExc_ValueError,
- "field value is required for Const");
- return NULL;
+ Py_INCREF(Py_None);
+ value = Py_None;
}
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p)
@@ -5988,7 +5987,7 @@
if (PyModule_AddIntConstant(m, "PyCF_NO_OPTIMIZE", PyCF_NO_OPTIMIZE) <
0)
return;
- if (PyModule_AddStringConstant(m, "__version__", "62047") < 0)
+ if (PyModule_AddStringConstant(m, "__version__", "62816") < 0)
return;
if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return;
if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0)
More information about the Python-checkins
mailing list