summaryrefslogtreecommitdiffstats
path: root/Modules/_tkinter.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-08-17 18:39:25 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2001-08-17 18:39:25 (GMT)
commit339d0f720e86dc34837547c90d3003a4a68d7d46 (patch)
tree2059e5d02f490540e759800b127d50f3fcd8c2b5 /Modules/_tkinter.c
parentf75976617bb36c892ee8a0f6a6fd3caddbd38cea (diff)
downloadcpython-339d0f720e86dc34837547c90d3003a4a68d7d46.zip
cpython-339d0f720e86dc34837547c90d3003a4a68d7d46.tar.gz
cpython-339d0f720e86dc34837547c90d3003a4a68d7d46.tar.bz2
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.
Diffstat (limited to 'Modules/_tkinter.c')
-rw-r--r--Modules/_tkinter.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 9b73307..eedb0c1 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -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