summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-08-31 22:13:03 -0400
committerBenjamin Peterson <benjamin@python.org>2011-08-31 22:13:03 -0400
commit0224d4e6992fdc91d8c095c7657bfcd7ce7a07a8 (patch)
tree1c54b30efdc96ddf8d557e02075d6daf1dbf26a0
parent48e484fdde4295c755dd3d6df6d7f1633eb17f2b (diff)
downloadcpython-git-0224d4e6992fdc91d8c095c7657bfcd7ce7a07a8.tar.gz
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 a562d29af3..4df888f4c7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.2.3?
Core and Builtins
-----------------
+- Accept bytes for the AST string type. This is temporary until a proper fix in
+ 3.3.
+
- Issue #9200: The str.is* methods now work with strings that contain non-BMP
characters even in narrow Unicode builds.
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 8a7f8aec7f..249e18ddf4 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 8ba06ff39a..89c07cd602 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;
}