summaryrefslogtreecommitdiffstats
path: root/Python/Python-ast.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-07-22 15:55:02 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-07-22 15:55:02 (GMT)
commit86f088e8e50632ee28bbf2366d48b2e503244fcd (patch)
treefa658c23d22321616222a6a66715046702382090 /Python/Python-ast.c
parentdb57e8d186f028cdf472175f48b4aed99b32c972 (diff)
parent2193d2b72bc942a0c0b489a9c2759a6aefbeecdf (diff)
downloadcpython-86f088e8e50632ee28bbf2366d48b2e503244fcd.zip
cpython-86f088e8e50632ee28bbf2366d48b2e503244fcd.tar.gz
cpython-86f088e8e50632ee28bbf2366d48b2e503244fcd.tar.bz2
merge 3.2
Diffstat (limited to 'Python/Python-ast.c')
-rw-r--r--Python/Python-ast.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 96c6bf8..a186647 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -592,8 +592,25 @@ static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
return 0;
}
-#define obj2ast_identifier obj2ast_object
-#define obj2ast_string obj2ast_object
+static int obj2ast_stringlike(PyObject* obj, PyObject** out, PyArena* arena,
+ const char *name)
+{
+ if (!PyUnicode_CheckExact(name)) {
+ PyErr_Format(PyExc_TypeError, "AST %s must be of type str", name);
+ return 1;
+ }
+ return obj2ast_object(obj, out, arena);
+}
+
+static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
+{
+ return obj2ast_stringlike(obj, out, arena, "identifier");
+}
+
+static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
+{
+ return obj2ast_stringlike(obj, out, arena, "string");
+}
static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
{