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.
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 2eae03d..82d2999 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -176,6 +176,8 @@
Return the current default string encoding used by the Unicode \n\
implementation.";
+#ifdef Py_USING_UNICODE
+
static PyObject *
sys_setdefaultencoding(PyObject *self, PyObject *args)
{
@@ -193,6 +195,8 @@
\n\
Set the current default string encoding used by the Unicode implementation.";
+#endif
+
/*
* Cached interned string objects used for calling the profile and
* trace functions. Initialized by trace_init().
@@ -530,8 +534,10 @@
{"exc_info", (PyCFunction)sys_exc_info, METH_NOARGS, exc_info_doc},
{"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc},
{"exit", sys_exit, METH_OLDARGS, exit_doc},
+#ifdef Py_USING_UNICODE
{"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, METH_NOARGS,
getdefaultencoding_doc},
+#endif
#ifdef HAVE_DLOPEN
{"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS,
getdlopenflags_doc},
@@ -553,8 +559,10 @@
#ifdef USE_MALLOPT
{"mdebug", sys_mdebug, METH_VARARGS},
#endif
+#ifdef Py_USING_UNICODE
{"setdefaultencoding", sys_setdefaultencoding, METH_VARARGS,
setdefaultencoding_doc},
+#endif
{"setcheckinterval", sys_setcheckinterval, METH_VARARGS,
setcheckinterval_doc},
#ifdef HAVE_DLOPEN
@@ -782,9 +790,11 @@
PyDict_SetItemString(sysdict, "maxint",
v = PyInt_FromLong(PyInt_GetMax()));
Py_XDECREF(v);
+#ifdef Py_USING_UNICODE
PyDict_SetItemString(sysdict, "maxunicode",
v = PyInt_FromLong(PyUnicode_GetMax()));
Py_XDECREF(v);
+#endif
PyDict_SetItemString(sysdict, "builtin_module_names",
v = list_builtin_module_names());
Py_XDECREF(v);