diff Python/compile.c @ 24624:6445e44fcb78 legacy-trunk

Fix PEP 263 code --without-unicode. Fixes #591943.
author Martin v. Löwis <martin@v.loewis.de>
date Wed, 07 Aug 2002 12:33:18 +0000
parents 06f1e2fd05bc
children 43caa212b959
line wrap: on
line diff
--- a/Python/compile.c	Wed Aug 07 12:01:41 2002 +0000
+++ b/Python/compile.c	Wed Aug 07 12:33:18 2002 +0000
@@ -1185,6 +1185,9 @@
 static PyObject *
 decode_utf8(char **sPtr, char *end, char* encoding)
 {
+#ifndef Py_USING_UNICODE
+	abort();
+#else
 	PyObject *u, *v;
 	char *s, *t;
 	t = s = *sPtr;
@@ -1197,6 +1200,7 @@
 	v = PyUnicode_AsEncodedString(u, encoding, NULL);
 	Py_DECREF(u);
 	return v;
+#endif
 }
 
 static PyObject *
@@ -1312,12 +1316,18 @@
 			 strcmp(encoding, "iso-8859-1") != 0);
 	if (rawmode || strchr(s, '\\') == NULL) {
 		if (need_encoding) {
+#ifndef Py_USING_UNICODE
+			/* This should not happen - we never see any other
+			   encoding. */
+			abort();
+#else
 			PyObject* u = PyUnicode_DecodeUTF8(s, len, NULL);
 			if (u == NULL)
 				return NULL;
 			v = PyUnicode_AsEncodedString(u, encoding, NULL);
 			Py_DECREF(u);
 			return v;
+#endif
 		} else {
 			return PyString_FromStringAndSize(s, len);
 		}