]> git.ipfire.org Git - thirdparty/Python/cpython.git/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 0aa9a113147acc8898e5acf75d29fa22e0e5fad6..12813668ced0cdd0d821bd347926c57a6199fde6 100644 (file)
--- 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
 -------
 
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;
     }