Index: Lib/test/test_parser.py =================================================================== --- Lib/test/test_parser.py (revision 61352) +++ Lib/test/test_parser.py (working copy) @@ -45,6 +45,7 @@ self.check_suite("def f():\n" " if (yield):\n" " yield x\n") + self.check_suite('"\u1234"') def test_expressions(self): self.check_expr("foo(1)") @@ -84,6 +85,7 @@ self.check_expr("lambda x, *y, **z: 0") self.check_expr("(x for x in range(10))") self.check_expr("foo(x for x in range(10))") + self.check_expr('"\u1234"') def test_simple_expression(self): # expr_stmt Index: Modules/parsermodule.c =================================================================== --- Modules/parsermodule.c (revision 61352) +++ Modules/parsermodule.c (working copy) @@ -498,11 +498,12 @@ parser_do_parse(PyObject *args, PyObject *kw, char *argspec, int type) { char* string = 0; + int len = 0; PyObject* res = 0; static char *keywords[] = {"source", NULL}; - if (PyArg_ParseTupleAndKeywords(args, kw, argspec, keywords, &string)) { + if (PyArg_ParseTupleAndKeywords(args, kw, argspec, keywords, &string, &len)) { node* n = PyParser_SimpleParseString(string, (type == PyST_EXPR) ? eval_input : file_input); @@ -526,7 +527,7 @@ parser_expr(PyST_Object *self, PyObject *args, PyObject *kw) { NOTE(ARGUNUSED(self)) - return (parser_do_parse(args, kw, "s:expr", PyST_EXPR)); + return (parser_do_parse(args, kw, "s#:expr", PyST_EXPR)); } @@ -534,7 +535,7 @@ parser_suite(PyST_Object *self, PyObject *args, PyObject *kw) { NOTE(ARGUNUSED(self)) - return (parser_do_parse(args, kw, "s:suite", PyST_SUITE)); + return (parser_do_parse(args, kw, "s#:suite", PyST_SUITE)); } @@ -717,9 +718,9 @@ Py_DECREF(o); } } - temp_str = PyUnicode_AsString(temp); - len = PyUnicode_GET_SIZE(temp) + 1; - strn = (char *)PyObject_MALLOC(len); + temp_str = PyUnicode_AsStringAndSize(temp, &len); + strn = (char *)PyObject_MALLOC(len + 1); + strn[len] = '\0'; if (strn != NULL) (void) memcpy(strn, temp_str, len); Py_DECREF(temp);