diff options
| author | Benjamin Peterson <benjamin@python.org> | 2011-07-22 11:09:07 -0500 |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2011-07-22 11:09:07 -0500 |
| commit | f6639c9c8201eee770b6d1a62feb772a9dbbb593 (patch) | |
| tree | d6473f27a7b379e2308c15bfcc916f5fecaf6d70 /Parser | |
| parent | 4fb9e4f2e1910fdbe8932559a9b807ded60e53d1 (diff) | |
| download | cpython-f6639c9c8201eee770b6d1a62feb772a9dbbb593.tar.gz | |
None is ok for identifiers but not strings
Diffstat (limited to 'Parser')
| -rwxr-xr-x | Parser/asdl_c.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 6598375172..8a7f8aec7f 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -794,24 +794,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) |
