mirror of
https://github.com/python/cpython.git
synced 2025-07-28 13:44:43 +00:00
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
This commit is contained in:
parent
e52c31450d
commit
78821ddf8c
7 changed files with 70 additions and 22 deletions
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue