Index: Objects/unicodeobject.c =================================================================== --- Objects/unicodeobject.c (revision 88538) +++ Objects/unicodeobject.c (working copy) @@ -1462,7 +1462,7 @@ char lower[11]; /* Enough for any encoding shortcut */ if (encoding == NULL) - encoding = PyUnicode_GetDefaultEncoding(); + return PyUnicode_DecodeUTF8(s, size, errors); /* Shortcuts for common default encodings */ if (normalize_encoding(encoding, lower, sizeof(lower))) { @@ -1670,7 +1670,9 @@ } if (encoding == NULL) - encoding = PyUnicode_GetDefaultEncoding(); + return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode), + PyUnicode_GET_SIZE(unicode), + errors); /* Shortcuts for common default encodings */ if (normalize_encoding(encoding, lower, sizeof(lower))) { Index: Lib/test/test_unicode.py =================================================================== --- Lib/test/test_unicode.py (revision 88538) +++ Lib/test/test_unicode.py (working copy) @@ -1187,6 +1187,9 @@ self.assertEqual('hello'.encode('utf-16-be'), b'\000h\000e\000l\000l\000o') self.assertEqual('hello'.encode('latin-1'), b'hello') + # Default encoding is utf-8 + self.assertEqual('\u2603'.encode(), b'\xe2\x98\x83') + # Roundtrip safety for BMP (just the first 1024 chars) for c in range(1024): u = chr(c) Index: Lib/test/test_bytes.py =================================================================== --- Lib/test/test_bytes.py (revision 88538) +++ Lib/test/test_bytes.py (working copy) @@ -206,6 +206,8 @@ self.assertEqual(b.decode("utf8", "ignore"), "Hello world\n") self.assertEqual(b.decode(errors="ignore", encoding="utf8"), "Hello world\n") + # Default encoding is utf-8 + self.assertEqual(self.type2test(b'\xe2\x98\x83').decode(), '\u2603') def test_from_int(self): b = self.type2test(0)