diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 0b95aaa1e8d..c66082eb02d 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -807,7 +807,7 @@ def visitModule(self, mod): 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 f6e345c9168..ff79757c35d 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -604,7 +604,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; }