diff Python/ceval.c @ 51032:551257c8058a legacy-trunk

fix building the core with --disable-unicode I changed some bytearray methods to use strings instead of unicode like bytes_repr Also, bytearray.fromhex() can take strings as well as unicode
author Benjamin Peterson <benjamin@python.org>
date Sun, 25 Jan 2009 17:15:10 +0000
parents dbc14acdde37
children 994fe4df4af7
line wrap: on
line diff
--- a/Python/ceval.c	Sun Jan 25 10:39:15 2009 +0000
+++ b/Python/ceval.c	Sun Jan 25 17:15:10 2009 +0000
@@ -2933,8 +2933,11 @@
 			PyObject *keyword = kws[2*i];
 			PyObject *value = kws[2*i + 1];
 			int j;
-			if (keyword == NULL || !(PyString_Check(keyword) ||
-						 PyUnicode_Check(keyword))) {
+			if (keyword == NULL || !(PyString_Check(keyword)
+#ifdef Py_USING_UNICODE
+						 || PyUnicode_Check(keyword)
+#endif
+				    )) {
 				PyErr_Format(PyExc_TypeError,
 				    "%.200s() keywords must be strings",
 				    PyString_AsString(co->co_name));
@@ -3115,14 +3118,20 @@
 }
 
 
+
 static PyObject *
 kwd_as_string(PyObject *kwd) {
+#ifdef Py_USING_UNICODE
 	if (PyString_Check(kwd)) {
+#else
+		assert(PyString_Check(kwd));
+#endif
 		Py_INCREF(kwd);
 		return kwd;
+#ifdef Py_USING_UNICODE
 	}
-	else
-		return _PyUnicode_AsDefaultEncodedString(kwd, "replace");
+	return _PyUnicode_AsDefaultEncodedString(kwd, "replace");
+#endif
 }
 
 
@@ -4503,7 +4512,9 @@
 	else if (locals == Py_None)
 		locals = globals;
 	if (!PyString_Check(prog) &&
+#ifdef Py_USING_UNICODE
 	    !PyUnicode_Check(prog) &&
+#endif
 	    !PyCode_Check(prog) &&
 	    !PyFile_Check(prog)) {
 		PyErr_SetString(PyExc_TypeError,