Patch #445762: Support --disable-unicode

- Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled
- check for Py_USING_UNICODE in all places that use Unicode functions
- disables unicode literals, and the builtin functions
- add the types.StringTypes list
- remove Unicode literals from most tests.
This commit is contained in:
Martin v. Löwis 2001-08-17 18:39:25 +00:00
parent f75976617b
commit 339d0f720e
42 changed files with 465 additions and 185 deletions

View file

@ -255,6 +255,7 @@ AsString(PyObject *value, PyObject *tmp)
{
if (PyString_Check(value))
return PyString_AsString(value);
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(value)) {
PyObject *v = PyUnicode_AsUTF8String(value);
if (v == NULL)
@ -266,6 +267,7 @@ AsString(PyObject *value, PyObject *tmp)
Py_DECREF(v);
return PyString_AsString(v);
}
#endif
else {
PyObject *v = PyObject_Str(value);
if (v == NULL)
@ -520,6 +522,7 @@ AsObj(PyObject *value)
ckfree(FREECAST argv);
return result;
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(value)) {
#if TKMAJORMINOR <= 8001
/* In Tcl 8.1 we must use UTF-8 */
@ -542,6 +545,7 @@ AsObj(PyObject *value)
PyUnicode_GET_SIZE(value));
#endif /* TKMAJORMINOR > 8001 */
}
#endif
else {
PyObject *v = PyObject_Str(value);
if (!v)
@ -616,13 +620,16 @@ Tkapp_Call(PyObject *self, PyObject *args)
so would confuse applications that expect a string. */
char *s = Tcl_GetStringResult(interp);
char *p = s;
/* If the result contains any bytes with the top bit set,
it's UTF-8 and we should decode it to Unicode */
#ifdef Py_USING_UNICODE
while (*p != '\0') {
if (*p & 0x80)
break;
p++;
}
if (*p == '\0')
res = PyString_FromStringAndSize(s, (int)(p-s));
else {
@ -634,6 +641,10 @@ Tkapp_Call(PyObject *self, PyObject *args)
res = PyString_FromStringAndSize(s, (int)(p-s));
}
}
#else
p = strchr(p, '\0');
res = PyString_FromStringAndSize(s, (int)(p-s));
#endif
}
LEAVE_OVERLAP_TCL