summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-01-25 17:15:10 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-01-25 17:15:10 (GMT)
commit78821ddf8c8eeebf757d72c2989cc0accea155de (patch)
treec9ce0cdf40089bbc995de6138b237595b4cd51dd /Python
parente52c31450dfbe649b559b3fa96630d348b838c19 (diff)
downloadcpython-78821ddf8c8eeebf757d72c2989cc0accea155de.zip
cpython-78821ddf8c8eeebf757d72c2989cc0accea155de.tar.gz
cpython-78821ddf8c8eeebf757d72c2989cc0accea155de.tar.bz2
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
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c19
-rw-r--r--Python/formatter_unicode.c5
2 files changed, 20 insertions, 4 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 92a7653..4facda4 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2933,8 +2933,11 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
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 @@ fail: /* Jump here from prelude on failure */
}
+
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 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
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,
diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c
index 4f2e53f..5cf5bad 100644
--- a/Python/formatter_unicode.c
+++ b/Python/formatter_unicode.c
@@ -2,6 +2,9 @@
built-in formatter for unicode. That is, unicode.__format__(). */
#include "Python.h"
+
+#ifdef Py_USING_UNICODE
+
#include "../Objects/stringlib/unicodedefs.h"
#define FORMAT_STRING _PyUnicode_FormatAdvanced
@@ -11,3 +14,5 @@
will convert them to unicode. */
#include "../Objects/stringlib/formatter.h"
+
+#endif