Fix a couple of problems in generating the AST code:
* use %r instead of backticks since backticks are going away in Py3k
* PyArena_Malloc() already sets PyErr_NoMemory so we don't need to do it again
* the signature for ast2obj_int incorrectly used a bool, rather than a long
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 14859ee..4877853 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -47,7 +47,7 @@
# XXX this should be fixed for real
if i == -1 and 'GeneratorExp' in cur:
i = size + 3
- assert i != -1, "Impossible line %d to reflow: %s" % (size, `s`)
+ assert i != -1, "Impossible line %d to reflow: %r" % (size, s)
lines.append(padding + cur[:i])
if len(lines) == 1:
# find new size based on brace
@@ -299,10 +299,8 @@
emit('}', 1)
emit("p = (%s)PyArena_Malloc(arena, sizeof(*p));" % ctype, 1);
- emit("if (!p) {", 1)
- emit("PyErr_NoMemory();", 2)
+ emit("if (!p)", 1)
emit("return NULL;", 2)
- emit("}", 1)
if union:
self.emit_body_union(name, args, attrs)
else:
@@ -474,7 +472,7 @@
return PyBool_FromLong(b);
}
-static PyObject* ast2obj_int(bool b)
+static PyObject* ast2obj_int(long b)
{
return PyInt_FromLong(b);
}