Mercurial > cpython-lru_cache-weakref
diff Python/Python-ast.c @ 71456:75d56cf3020c
merge 3.2
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Fri, 22 Jul 2011 10:55:02 -0500 |
| parents | b23ad0a6cf87 3301689bd78d |
| children | 34d0b02a01e4 |
line wrap: on
line diff
--- a/Python/Python-ast.c Thu Jul 21 19:49:47 2011 +0200 +++ b/Python/Python-ast.c Fri Jul 22 10:55:02 2011 -0500 @@ -592,8 +592,25 @@ 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) {
