summaryrefslogtreecommitdiffstats
path: root/Parser/asdl_c.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-08-09 21:08:39 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-08-09 21:08:39 (GMT)
commite2498419034eade424fa744e1505980e64ba759b (patch)
tree22fe40b438aebff64ba9ab784a79cebce252cd23 /Parser/asdl_c.py
parent18205baf251495b5a54b08c1f9b0e1763eb27aa1 (diff)
downloadcpython-e2498419034eade424fa744e1505980e64ba759b.zip
cpython-e2498419034eade424fa744e1505980e64ba759b.tar.gz
cpython-e2498419034eade424fa744e1505980e64ba759b.tar.bz2
add a asdl bytes type, so Bytes.s be properly typechecked
Diffstat (limited to 'Parser/asdl_c.py')
-rwxr-xr-xParser/asdl_c.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 432d7b7..0b95aaa 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -776,6 +776,7 @@ static PyObject* ast2obj_object(void *o)
}
#define ast2obj_identifier ast2obj_object
#define ast2obj_string ast2obj_object
+#define ast2obj_bytes ast2obj_object
static PyObject* ast2obj_int(long b)
{
@@ -813,6 +814,15 @@ static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
return obj2ast_object(obj, out, arena);
}
+static int obj2ast_bytes(PyObject* obj, PyObject** out, PyArena* arena)
+{
+ if (!PyBytes_CheckExact(obj)) {
+ PyErr_SetString(PyExc_TypeError, "AST bytes must be of type bytes");
+ return 1;
+ }
+ return obj2ast_object(obj, out, arena);
+}
+
static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
{
int i;