diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-07-22 10:55:02 -0500 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-07-22 10:55:02 -0500 |
commit | 9f313cce3b955df20d47cb2165e67b6f72db84cd (patch) | |
tree | f293efd2ad8c9d3917545d64ae7d51c188e3e466 /Python/Python-ast.c | |
parent | 02fa185e49b01a43a95ec404d6435fefc906cd11 (diff) | |
parent | 7848f2a4be885c95dc41d479377d063547e46fb3 (diff) | |
download | cpython-9f313cce3b955df20d47cb2165e67b6f72db84cd.tar.gz |
merge 3.2
Diffstat (limited to 'Python/Python-ast.c')
-rw-r--r-- | Python/Python-ast.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 96c6bf83fc..a1866470d5 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) { |