diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-07-22 16:10:43 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-07-22 16:10:43 (GMT) |
commit | 8a4b42b7f4ca0458a5a4aae24f42e207309b19b2 (patch) | |
tree | 054b19360fe01f678849aa10a1f3682ec98ac555 /Python/Python-ast.c | |
parent | 51a6b371f924217246692c6e65a4b6617128e8a9 (diff) | |
parent | 180e63507dde824afb48ea9c1649755b79258935 (diff) | |
download | cpython-8a4b42b7f4ca0458a5a4aae24f42e207309b19b2.zip cpython-8a4b42b7f4ca0458a5a4aae24f42e207309b19b2.tar.gz cpython-8a4b42b7f4ca0458a5a4aae24f42e207309b19b2.tar.bz2 |
merge 3.2
Diffstat (limited to 'Python/Python-ast.c')
-rw-r--r-- | Python/Python-ast.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c index a186647..68b1097 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -592,24 +592,22 @@ static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena) return 0; } -static int obj2ast_stringlike(PyObject* obj, PyObject** out, PyArena* arena, - const char *name) +static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena) { - if (!PyUnicode_CheckExact(name)) { - PyErr_Format(PyExc_TypeError, "AST %s must be of type str", name); + if (!PyUnicode_CheckExact(obj) && obj != Py_None) { + PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str"); 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"); + if (!PyUnicode_CheckExact(obj)) { + PyErr_SetString(PyExc_TypeError, "AST string must be of type str"); + return 1; + } + return obj2ast_object(obj, out, arena); } static int obj2ast_int(PyObject* obj, int* out, PyArena* arena) |