diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-01-25 17:15:10 +0000 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-01-25 17:15:10 +0000 |
commit | 78821ddf8c8eeebf757d72c2989cc0accea155de (patch) | |
tree | c9ce0cdf40089bbc995de6138b237595b4cd51dd /Python/ceval.c | |
parent | e52c31450dfbe649b559b3fa96630d348b838c19 (diff) | |
download | cpython-git-78821ddf8c8eeebf757d72c2989cc0accea155de.tar.gz |
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/ceval.c')
-rw-r--r-- | Python/ceval.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 92a7653e05..4facda4810 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, |