Index: Python/ast.c =================================================================== --- Python/ast.c (Revision 60048) +++ Python/ast.c (Arbeitskopie) @@ -3238,6 +3238,9 @@ quote = *++s; unicode = 1; } + if (quote == 'b' || quote == 'B') { + quote = *++s; + } if (quote == 'r' || quote == 'R') { quote = *++s; rawmode = 1; Index: Python/bltinmodule.c =================================================================== --- Python/bltinmodule.c (Revision 60048) +++ Python/bltinmodule.c (Arbeitskopie) @@ -2446,6 +2446,7 @@ SETBUILTIN("True", Py_True); SETBUILTIN("basestring", &PyBaseString_Type); SETBUILTIN("bool", &PyBool_Type); + SETBUILTIN("bytes", &PyString_Type); SETBUILTIN("buffer", &PyBuffer_Type); SETBUILTIN("classmethod", &PyClassMethod_Type); #ifndef WITHOUT_COMPLEX Index: Parser/tokenizer.c =================================================================== --- Parser/tokenizer.c (Revision 60048) +++ Parser/tokenizer.c (Arbeitskopie) @@ -1263,6 +1263,14 @@ if (isalpha(c) || c == '_') { /* Process r"", u"" and ur"" */ switch (c) { + case 'b': + case 'B': + c = tok_nextc(tok); + if (c == 'r' || c == 'R') + c = tok_nextc(tok); + if (c == '"' || c == '\'') + goto letter_quote; + break; case 'r': case 'R': c = tok_nextc(tok); Index: Lib/test/test_string.py =================================================================== --- Lib/test/test_string.py (Revision 60048) +++ Lib/test/test_string.py (Arbeitskopie) @@ -106,8 +106,19 @@ self.assertEqual(string.capwords('ABC-DEF-GHI', '-'), 'Abc-Def-Ghi') self.assertEqual(string.capwords('ABC-def DEF-ghi GHI'), 'Abc-def Def-ghi Ghi') +class BytesAliasTest(unittest.TestCase): + + def test_builtin(self): + self.assert_(str is bytes) + + def test_syntax(self): + self.assertEqual(b"spam", "spam") + self.assertEqual(br"egg\foo", "egg\\foo") + self.assert_(type(b""), str) + self.assert_(type(br""), str) + def test_main(): - test_support.run_unittest(StringTest, ModuleTest) + test_support.run_unittest(StringTest, ModuleTest, BytesAliasTest) if __name__ == "__main__": test_main()