]> granicus.if.org Git - python/commitdiff
accept bytes for the AST 'string' type
authorBenjamin Peterson <benjamin@python.org>
Thu, 1 Sep 2011 02:13:03 +0000 (22:13 -0400)
committerBenjamin Peterson <benjamin@python.org>
Thu, 1 Sep 2011 02:13:03 +0000 (22:13 -0400)
This is a temporary kludge and all is well in 3.3.

Misc/NEWS
Parser/asdl_c.py
Python/Python-ast.c

index a562d29af3ab29221a492712eaadc273e773eb5a..4df888f4c7ce93574ccda691e6de32324165e190 100644 (file)
--- 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.
 
index 8a7f8aec7f4b13f45c6ff80924057af264fe8bae..249e18ddf42494fbcf93dd5822b0d698008f02fc 100755 (executable)
@@ -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;
     }
index 8ba06ff39a4b709b6a6ab12108989f43fd3343c5..89c07cd602d2ab017e3d35feb42f7282d18f0234 100644 (file)
@@ -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;
     }