diff Objects/bytesobject.c @ 47496:2284fa89ab08

Move the codec decode type checks to bytes/bytearray.decode(). Use faster PyUnicode_FromEncodedObject() for bytes/bytearray.decode(). Add new PyCodec_KnownEncoding() API. Add new PyUnicode_AsDecodedUnicode() and PyUnicode_AsEncodedUnicode() APIs. Add missing PyUnicode_AsDecodedObject() to unicodeobject.h Fix punicode codec to also work on memoryviews.
author Marc-André Lemburg <mal@egenix.com>
date Fri, 06 Jun 2008 12:18:17 +0000
parents 58f4b60773fe
children bf50085fbcd3
line wrap: on
line diff
--- a/Objects/bytesobject.c	Fri Jun 06 11:49:51 2008 +0000
+++ b/Objects/bytesobject.c	Fri Jun 06 12:18:17 2008 +0000
@@ -2713,7 +2713,7 @@
 		return NULL;
 	if (encoding == NULL)
 		encoding = PyUnicode_GetDefaultEncoding();
-	return PyCodec_Decode(self, encoding, errors);
+	return PyUnicode_FromEncodedObject(self, encoding, errors);
 }
 
 
@@ -2899,7 +2899,7 @@
 					"string argument without an encoding");
 			return NULL;
 		}
-		new = PyCodec_Encode(x, encoding, errors);
+		new = PyUnicode_AsEncodedString(x, encoding, errors);
 		if (new == NULL)
 			return NULL;
 		assert(PyBytes_Check(new));