summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-09-01 02:13:03 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-09-01 02:13:03 (GMT)
commit4058211e8d8c250e39e21604b36637ebd8784e6c (patch)
tree2a4974654904b30228c132c50ddcdf97ce535e55
parent89b7af1e532f4a12632e77173e71717f2e9996e8 (diff)
downloadcpython-4058211e8d8c250e39e21604b36637ebd8784e6c.zip
cpython-4058211e8d8c250e39e21604b36637ebd8784e6c.tar.gz
cpython-4058211e8d8c250e39e21604b36637ebd8784e6c.tar.bz2
accept bytes for the AST 'string' type
This is a temporary kludge and all is well in 3.3.
-rw-r--r--Misc/NEWS3
-rwxr-xr-xParser/asdl_c.py2
-rw-r--r--Python/Python-ast.c2
3 files changed, 5 insertions, 2 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 0aa9a11..1281366 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,6 +13,9 @@ Core and Builtins
- Issue #12326: sys.platform is now always 'linux2' on Linux, even if Python
is compiled on Linux 3.
+- Accept bytes for the AST string type. This is temporary until a proper fix in
+ 3.3.
+
Library
-------
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 8a7f8ae..249e18d 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -805,7 +805,7 @@ static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
{
- if (!PyUnicode_CheckExact(obj)) {
+ if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
return 1;
}
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 8ba06ff..89c07cd 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -611,7 +611,7 @@ static int obj2ast_identifier(PyObject* obj, PyObject** out, PyArena* arena)
static int obj2ast_string(PyObject* obj, PyObject** out, PyArena* arena)
{
- if (!PyUnicode_CheckExact(obj)) {
+ if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
return 1;
}