diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-12-06 17:41:04 -0500 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-12-06 17:41:04 -0500 |
commit | 442f20996dcd994d1024e5cad7f66a4595352eb2 (patch) | |
tree | 641746efd4247acd2b5e13f5de7f65c026242a05 /Parser/asdl_c.py | |
parent | 4b237e3b1112304f834ac78fe05abdecbf3d87b4 (diff) | |
download | cpython-git-442f20996dcd994d1024e5cad7f66a4595352eb2.tar.gz |
create NameConstant AST class for None, True, and False literals (closes #16619)
Diffstat (limited to 'Parser/asdl_c.py')
-rwxr-xr-x | Parser/asdl_c.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index a9e6626ab4..9557ba0cf2 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -820,6 +820,7 @@ static PyObject* ast2obj_object(void *o) Py_INCREF((PyObject*)o); return (PyObject*)o; } +#define ast2obj_singleton ast2obj_object #define ast2obj_identifier ast2obj_object #define ast2obj_string ast2obj_object #define ast2obj_bytes ast2obj_object @@ -831,6 +832,17 @@ static PyObject* ast2obj_int(long b) /* Conversion Python -> AST */ +static int obj2ast_singleton(PyObject *obj, PyObject** out, PyArena* arena) +{ + if (obj != Py_None && obj != Py_True && obj != Py_False) { + PyErr_SetString(PyExc_ValueError, + "AST singleton must be True, False, or None"); + return 1; + } + *out = obj; + return 0; +} + static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena) { if (obj == Py_None) |