[Python-3000-checkins] r55410 - python/branches/py3k-struni/Modules/cjkcodecs/cjkcodecs.h

guido.van.rossum python-3000-checkins at python.org
Thu May 17 20:56:42 CEST 2007


Author: guido.van.rossum
Date: Thu May 17 20:56:39 2007
New Revision: 55410

Modified:
   python/branches/py3k-struni/Modules/cjkcodecs/cjkcodecs.h
Log:
Allow encoding names to be unicode strings.


Modified: python/branches/py3k-struni/Modules/cjkcodecs/cjkcodecs.h
==============================================================================
--- python/branches/py3k-struni/Modules/cjkcodecs/cjkcodecs.h	(original)
+++ python/branches/py3k-struni/Modules/cjkcodecs/cjkcodecs.h	Thu May 17 20:56:39 2007
@@ -261,6 +261,11 @@
 	const MultibyteCodec *codec;
 	const char *enc;
 
+        if (PyUnicode_Check(encoding)) {
+		encoding = _PyUnicode_AsDefaultEncodedString(encoding, NULL);
+		if (encoding == NULL)
+			return NULL;
+	}
 	if (!PyString_Check(encoding)) {
 		PyErr_SetString(PyExc_TypeError,
 				"encoding name must be a string.");


More information about the Python-3000-checkins mailing list