Index: Makefile.pre.in =================================================================== RCS file: /cvsroot/python/python/dist/src/Makefile.pre.in,v retrieving revision 1.47 diff -u -r1.47 Makefile.pre.in --- Makefile.pre.in 2001/08/02 04:15:00 1.47 +++ Makefile.pre.in 2001/08/02 05:55:36 @@ -139,6 +139,7 @@ DLINCLDIR= @DLINCLDIR@ DYNLOADFILE= @DYNLOADFILE@ MACHDEP_OBJS= @MACHDEP_OBJS@ +UNICODE_OBJS= @UNICODE_OBJS@ PYTHON= python$(EXE) @@ -255,8 +256,7 @@ Objects/stringobject.o \ Objects/tupleobject.o \ Objects/typeobject.o \ - Objects/unicodeobject.o \ - Objects/unicodectype.o + $(UNICODE_OBJS) ########################################################################## Index: configure.in =================================================================== RCS file: /cvsroot/python/python/dist/src/configure.in,v retrieving revision 1.236 diff -u -r1.236 configure.in --- configure.in 2001/07/26 13:41:05 1.236 +++ configure.in 2001/08/02 05:55:38 @@ -1614,10 +1614,13 @@ ;; esac +AC_SUBST(UNICODE_OBJS) if test "$enable_unicode" = "no" then + UNICODE_OBJS="" AC_MSG_RESULT(not used) else + UNICODE_OBJS="Objects/unicodeobject.o Objects/unicodectype.o" AC_DEFINE(Py_USING_UNICODE) if test "$unicode_size" = "$ac_cv_sizeof_wchar_t" then Index: setup.py =================================================================== RCS file: /cvsroot/python/python/dist/src/setup.py,v retrieving revision 1.44 diff -u -r1.44 setup.py --- setup.py 2001/07/26 21:34:59 1.44 +++ setup.py 2001/08/02 05:55:39 @@ -160,6 +160,11 @@ if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' ) + try: + have_unicode = unicode + except NameError: + have_unicode = 0 + # lib_dirs and inc_dirs are used to search for files; # if a file is found in one of those directories, it can # be assumed that no additional -I,-L directives are needed. @@ -210,7 +215,8 @@ # Python C API test module exts.append( Extension('_testcapi', ['_testcapimodule.c']) ) # static Unicode character database - exts.append( Extension('unicodedata', ['unicodedata.c']) ) + if have_unicode: + exts.append( Extension('unicodedata', ['unicodedata.c']) ) # access to ISO C locale support exts.append( Extension('_locale', ['_localemodule.c']) ) Index: Include/intobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/intobject.h,v retrieving revision 2.21 diff -u -r2.21 intobject.h --- Include/intobject.h 2000/09/01 23:29:26 2.21 +++ Include/intobject.h 2001/08/02 05:55:40 @@ -30,7 +30,9 @@ #define PyInt_Check(op) ((op)->ob_type == &PyInt_Type) extern DL_IMPORT(PyObject *) PyInt_FromString(char*, char**, int); +#ifdef Py_USING_UNICODE extern DL_IMPORT(PyObject *) PyInt_FromUnicode(Py_UNICODE*, int, int); +#endif extern DL_IMPORT(PyObject *) PyInt_FromLong(long); extern DL_IMPORT(long) PyInt_AsLong(PyObject *); extern DL_IMPORT(long) PyInt_GetMax(void); Index: Include/longobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/longobject.h,v retrieving revision 2.20 diff -u -r2.20 longobject.h --- Include/longobject.h 2001/06/11 21:23:58 2.20 +++ Include/longobject.h 2001/08/02 05:55:40 @@ -42,7 +42,9 @@ #endif /* HAVE_LONG_LONG */ DL_IMPORT(PyObject *) PyLong_FromString(char *, char **, int); +#ifdef Py_USING_UNICODE DL_IMPORT(PyObject *) PyLong_FromUnicode(Py_UNICODE*, int, int); +#endif /* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in base 256, and return a Python long with the same numeric value. Index: Include/object.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/object.h,v retrieving revision 2.80 diff -u -r2.80 object.h --- Include/object.h 2001/08/02 04:15:00 2.80 +++ Include/object.h 2001/08/02 05:55:40 @@ -308,7 +308,9 @@ extern DL_IMPORT(void) _PyObject_Dump(PyObject *); extern DL_IMPORT(PyObject *) PyObject_Repr(PyObject *); extern DL_IMPORT(PyObject *) PyObject_Str(PyObject *); +#ifdef Py_USING_UNICODE extern DL_IMPORT(PyObject *) PyObject_Unicode(PyObject *); +#endif extern DL_IMPORT(int) PyObject_Compare(PyObject *, PyObject *); extern DL_IMPORT(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); extern DL_IMPORT(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); Index: Include/unicodeobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/unicodeobject.h,v retrieving revision 2.29 diff -u -r2.29 unicodeobject.h --- Include/unicodeobject.h 2001/07/31 14:30:16 2.29 +++ Include/unicodeobject.h 2001/08/02 05:55:41 @@ -58,6 +58,12 @@ /* --- Internal Unicode Format -------------------------------------------- */ +#ifndef Py_USING_UNICODE + +#define PyUnicode_Check(op) 0 + +#else + /* FIXME: MvL's new implementation assumes that Py_UNICODE_SIZE is properly set, but the default rules below doesn't set it. I'll sort this out some other day -- fredrik@pythonware.com */ @@ -1093,4 +1113,5 @@ #ifdef __cplusplus } #endif +#endif /* Py_USING_UNICODE */ #endif /* !Py_UNICODEOBJECT_H */ Index: Lib/ConfigParser.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v retrieving revision 1.33 diff -u -r1.33 ConfigParser.py --- Lib/ConfigParser.py 2001/07/06 17:22:48 1.33 +++ Lib/ConfigParser.py 2001/08/02 05:55:41 @@ -230,7 +230,7 @@ configuration files in the list will be read. A single filename may also be given. """ - if type(filenames) in [type(''), type(u'')]: + if type(filenames) in types.StringTypes: filenames = [filenames] for filename in filenames: try: Index: Lib/copy.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/copy.py,v retrieving revision 1.19 diff -u -r1.19 copy.py --- Lib/copy.py 2001/01/20 19:54:20 1.19 +++ Lib/copy.py 2001/08/02 05:55:42 @@ -91,8 +91,11 @@ d[types.LongType] = _copy_atomic d[types.FloatType] = _copy_atomic d[types.StringType] = _copy_atomic -d[types.UnicodeType] = _copy_atomic try: + d[types.UnicodeType] = _copy_atomic +except AttributeError: + pass +try: d[types.CodeType] = _copy_atomic except AttributeError: pass @@ -170,7 +173,10 @@ d[types.LongType] = _deepcopy_atomic d[types.FloatType] = _deepcopy_atomic d[types.StringType] = _deepcopy_atomic -d[types.UnicodeType] = _deepcopy_atomic +try: + d[types.UnicodeType] = _deepcopy_atomic +except AttributeError: + pass d[types.CodeType] = _deepcopy_atomic d[types.TypeType] = _deepcopy_atomic d[types.XRangeType] = _deepcopy_atomic Index: Lib/types.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/types.py,v retrieving revision 1.17 diff -u -r1.17 types.py --- Lib/types.py 2001/08/02 04:15:00 1.17 +++ Lib/types.py 2001/08/02 05:55:43 @@ -19,7 +19,12 @@ pass StringType = type('') -UnicodeType = type(u'') +try: + UnicodeType = type(unicode("")) + StringTypes = [StringType, UnicodeType] +except NameError: + StringTypes = [StringType] + BufferType = type(buffer('')) TupleType = type(()) Index: Lib/test/test_support.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v retrieving revision 1.24 diff -u -r1.24 test_support.py --- Lib/test/test_support.py 2001/07/16 18:51:32 1.24 +++ Lib/test/test_support.py 2001/08/02 05:55:44 @@ -63,10 +63,13 @@ TESTFN = '$test' elif os.name != 'riscos': TESTFN = '@test' - # Unicode name only used if TEST_FN_ENCODING exists for the platform. - TESTFN_UNICODE=u"@test-\xe0\xf2" # 2 latin characters. - if os.name=="nt": - TESTFN_ENCODING="mbcs" + try: + # Unicode name only used if TEST_FN_ENCODING exists for the platform. + TESTFN_UNICODE=unicode("@test-\xe0\xf2", "latin-1") # 2 latin characters. + if os.name=="nt": + TESTFN_ENCODING="mbcs" + except NameError: + pass else: TESTFN = 'test' del os Index: Modules/_codecsmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_codecsmodule.c,v retrieving revision 2.8 diff -u -r2.8 _codecsmodule.c --- Modules/_codecsmodule.c 2001/06/26 15:11:00 2.8 +++ Modules/_codecsmodule.c 2001/08/02 05:55:45 @@ -71,6 +71,7 @@ return NULL; } +#ifdef Py_USING_UNICODE /* --- Helpers ------------------------------------------------------------ */ static @@ -621,12 +622,14 @@ } #endif /* MS_WIN32 */ +#endif /* Py_USING_UNICODE */ /* --- Module API --------------------------------------------------------- */ static PyMethodDef _codecs_functions[] = { {"register", codecregister, 1}, {"lookup", codeclookup, 1}, +#ifdef Py_USING_UNICODE {"utf_8_encode", utf_8_encode, 1}, {"utf_8_decode", utf_8_decode, 1}, {"utf_16_encode", utf_16_encode, 1}, @@ -654,6 +657,7 @@ {"mbcs_encode", mbcs_encode, 1}, {"mbcs_decode", mbcs_decode, 1}, #endif +#endif /* Py_USING_UNICODE */ {NULL, NULL} /* sentinel */ }; Index: Modules/_sre.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v retrieving revision 2.61 diff -u -r2.61 _sre.c --- Modules/_sre.c 2001/07/08 13:26:57 2.61 +++ Modules/_sre.c 2001/08/02 05:55:46 @@ -63,7 +63,7 @@ /* defining this one enables tracing */ #undef VERBOSE -#if PY_VERSION_HEX >= 0x01060000 +#if PY_VERSION_HEX >= 0x01060000 && defined(Py_USING_UNICODE) /* defining this enables unicode support (default under 1.6a1 and later) */ #define HAVE_UNICODE #endif Index: Modules/_tkinter.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v retrieving revision 1.117 diff -u -r1.117 _tkinter.c --- Modules/_tkinter.c 2001/07/16 19:32:52 1.117 +++ Modules/_tkinter.c 2001/08/02 05:55:46 @@ -262,6 +262,7 @@ { 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) @@ -273,6 +274,7 @@ Py_DECREF(v); return PyString_AsString(v); } +#endif else { PyObject *v = PyObject_Str(value); if (v == NULL) @@ -527,6 +529,7 @@ 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 */ @@ -549,6 +552,7 @@ PyUnicode_GET_SIZE(value)); #endif /* TKMAJORMINOR > 8001 */ } +#endif else { PyObject *v = PyObject_Str(value); if (!v) @@ -623,13 +627,16 @@ 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 { @@ -641,6 +648,10 @@ res = PyString_FromStringAndSize(s, (int)(p-s)); } } +#else + p = strchr(p, '\0'); + res = PyString_FromStringAndSize(s, (int)(p-s)); +#endif } LEAVE_OVERLAP_TCL Index: Modules/cPickle.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v retrieving revision 2.61 diff -u -r2.61 cPickle.c --- Modules/cPickle.c 2001/08/02 04:15:00 2.61 +++ Modules/cPickle.c 2001/08/02 05:55:48 @@ -1172,6 +1172,7 @@ } +#ifdef Py_USING_UNICODE /* A copy of PyUnicode_EncodeRawUnicodeEscape() that also translates backslash and newline characters to \uXXXX escapes. */ static PyObject * @@ -1289,6 +1290,7 @@ Py_XDECREF(repr); return -1; } +#endif static int @@ -1824,11 +1826,13 @@ goto finally; } +#ifdef Py_USING_UNICODE case 'u': if ((type == &PyUnicode_Type) && (PyString_GET_SIZE(args) < 2)) { res = save_unicode(self, args, 0); goto finally; } +#endif } if (args->ob_refcnt > 1) { @@ -1857,12 +1861,14 @@ } break; +#ifdef Py_USING_UNICODE case 'u': if (type == &PyUnicode_Type) { res = save_unicode(self, args, 1); goto finally; } break; +#endif case 't': if (type == &PyTuple_Type) { @@ -2818,6 +2824,7 @@ } +#ifdef Py_USING_UNICODE static int load_unicode(Unpicklerobject *self) { PyObject *str = 0; @@ -2836,8 +2843,10 @@ finally: return res; } +#endif +#ifdef Py_USING_UNICODE static int load_binunicode(Unpicklerobject *self) { PyObject *unicode; @@ -2857,6 +2866,7 @@ PDATA_PUSH(self->stack, unicode, -1); return 0; } +#endif static int @@ -3615,6 +3625,7 @@ break; continue; +#ifdef Py_USING_UNICODE case UNICODE: if (load_unicode(self) < 0) break; @@ -3624,6 +3635,7 @@ if (load_binunicode(self) < 0) break; continue; +#endif case EMPTY_TUPLE: if (load_empty_tuple(self) < 0) @@ -3905,6 +3917,7 @@ break; continue; +#ifdef Py_USING_UNICODE case UNICODE: if (load_unicode(self) < 0) break; @@ -3914,6 +3927,7 @@ if (load_binunicode(self) < 0) break; continue; +#endif case EMPTY_TUPLE: if (load_empty_tuple(self) < 0) Index: Modules/pyexpat.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/pyexpat.c,v retrieving revision 2.47 diff -u -r2.47 pyexpat.c --- Modules/pyexpat.c 2001/07/28 09:36:36 2.47 +++ Modules/pyexpat.c 2001/08/02 05:55:49 @@ -28,6 +28,11 @@ #define Py_TPFLAGS_GC 0 #endif +#if (PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION > 5) || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 2) +/* In Python 1.6, 2.0 and 2.1, disabling Unicode was not possible. */ +#define Py_USING_UNICODE +#endif + enum HandlerTypes { StartElement, EndElement, @@ -173,7 +178,7 @@ } #endif -#if !(PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6) +#ifdef Py_USING_UNICODE #if EXPAT_VERSION == 0x010200 static PyObject * conv_atts_using_unicode(XML_Char **atts) @@ -370,7 +375,7 @@ return res; } -#if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 +#ifndef Py_USING_UNICODE #define STRING_CONV_FUNC conv_string_to_utf8 #else /* Python 1.6 and later versions */ @@ -506,7 +511,7 @@ const XML_Char *data), ("(O&O&)",STRING_CONV_FUNC,target, STRING_CONV_FUNC,data)) -#if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 +#ifndef Py_USING_UNICODE VOID_HANDLER(CharacterData, (void *userData, const XML_Char *data, int len), ("(N)", conv_string_len_to_utf8(data,len))) @@ -531,7 +536,7 @@ STRING_CONV_FUNC,notationName)) #if EXPAT_VERSION >= 0x015f00 -#if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 +#ifndef Py_USING_UNICODE VOID_HANDLER(EntityDecl, (void *userData, const XML_Char *entityName, @@ -608,7 +613,7 @@ return conv_content_model(model, conv_string_to_utf8); } -#if !(PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6) +#ifdef Py_USING_UNICODE static PyObject * conv_content_model_unicode(XML_Content * const model) { @@ -678,7 +683,7 @@ (void *userData), ("()")) -#if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 +#ifndef Py_USING_UNICODE VOID_HANDLER(Default, (void *userData, const XML_Char *s, int len), ("(N)", conv_string_len_to_utf8(s,len))) @@ -1064,7 +1069,7 @@ /* ---------- */ -#if !(PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6) +#ifdef Py_USING_UNICODE /* pyexpat international encoding support. @@ -1158,8 +1163,7 @@ return NULL; } XML_SetUserData(self->itself, (void *)self); -#if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 -#else +#ifdef Py_USING_UNICODE XML_SetUnknownEncodingHandler(self->itself, (XML_UnknownEncodingHandler) PyUnknownEncodingHandler, NULL); #endif @@ -1292,7 +1296,7 @@ } if (strcmp(name, "returns_unicode") == 0) { if (PyObject_IsTrue(v)) { -#if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 +#ifndef Py_USING_UNICODE PyErr_SetString(PyExc_ValueError, "Cannot return Unicode strings in Python 1.5"); return -1; @@ -1545,8 +1557,7 @@ info.minor, info.micro)); } #endif -#if PY_MAJOR_VERSION == 1 && PY_MINOR_VERSION < 6 -#else +#ifdef Py_USING_UNICODE init_template_buffer(); #endif /* XXX When Expat supports some way of figuring out how it was Index: Objects/abstract.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v retrieving revision 2.70 diff -u -r2.70 abstract.c --- Objects/abstract.c 2001/08/02 04:15:00 2.70 +++ Objects/abstract.c 2001/08/02 05:55:49 @@ -569,8 +569,10 @@ { if (PyString_Check(v)) return PyString_Format(v, w); +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(v)) return PyUnicode_Format(v, w); +#endif return binary_op(v, w, NB_SLOT(nb_remainder), "%"); } @@ -677,8 +679,10 @@ { if (PyString_Check(v)) return PyString_Format(v, w); +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(v)) return PyUnicode_Format(v, w); +#endif else return binary_iop(v, w, NB_SLOT(nb_inplace_remainder), NB_SLOT(nb_remainder), "%="); @@ -791,10 +795,12 @@ if (PyString_Check(o)) return int_from_string(PyString_AS_STRING(o), PyString_GET_SIZE(o)); +#ifdef Py_USING_UNICODE if (PyUnicode_Check(o)) return PyInt_FromUnicode(PyUnicode_AS_UNICODE(o), PyUnicode_GET_SIZE(o), 10); +#endif m = o->ob_type->tp_as_number; if (m && m->nb_int) return m->nb_int(o); @@ -843,11 +849,13 @@ */ return long_from_string(PyString_AS_STRING(o), PyString_GET_SIZE(o)); +#ifdef Py_USING_UNICODE if (PyUnicode_Check(o)) /* The above check is done in PyLong_FromUnicode(). */ return PyLong_FromUnicode(PyUnicode_AS_UNICODE(o), PyUnicode_GET_SIZE(o), 10); +#endif m = o->ob_type->tp_as_number; if (m && m->nb_long) return m->nb_long(o); Index: Objects/complexobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v retrieving revision 2.36 diff -u -r2.36 complexobject.c --- Objects/complexobject.c 2001/08/02 04:15:00 2.36 +++ Objects/complexobject.c 2001/08/02 05:55:49 @@ -605,6 +605,7 @@ s = PyString_AS_STRING(v); len = PyString_GET_SIZE(v); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(v)) { if (PyUnicode_GET_SIZE(v) >= sizeof(s_buffer)) { PyErr_SetString(PyExc_ValueError, @@ -619,6 +620,7 @@ s = s_buffer; len = (int)strlen(s); } +#endif else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, "complex() arg is not a string"); Index: Objects/floatobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v retrieving revision 2.84 diff -u -r2.84 floatobject.c --- Objects/floatobject.c 2001/08/02 04:15:00 2.84 +++ Objects/floatobject.c 2001/08/02 05:55:50 @@ -109,7 +109,9 @@ const char *s, *last, *end; double x; char buffer[256]; /* for errors */ +#ifdef Py_USING_UNICODE char s_buffer[256]; /* for objects convertible to a char buffer */ +#endif int len; if (pend) @@ -118,6 +120,7 @@ s = PyString_AS_STRING(v); len = PyString_GET_SIZE(v); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(v)) { if (PyUnicode_GET_SIZE(v) >= sizeof(s_buffer)) { PyErr_SetString(PyExc_ValueError, @@ -132,6 +135,7 @@ s = s_buffer; len = (int)strlen(s); } +#endif else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, "float() needs a string argument"); Index: Objects/intobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v retrieving revision 2.60 diff -u -r2.60 intobject.c --- Objects/intobject.c 2001/08/02 04:15:00 2.60 +++ Objects/intobject.c 2001/08/02 05:55:50 @@ -202,6 +202,7 @@ return PyInt_FromLong(x); } +#ifdef Py_USING_UNICODE PyObject * PyInt_FromUnicode(Py_UNICODE *s, int length, int base) { @@ -216,6 +217,7 @@ return NULL; return PyInt_FromString(buffer, NULL, base); } +#endif /* Methods */ @@ -759,10 +761,12 @@ return PyNumber_Int(x); if (PyString_Check(x)) return PyInt_FromString(PyString_AS_STRING(x), NULL, base); +#ifdef Py_USING_UNICODE if (PyUnicode_Check(x)) return PyInt_FromUnicode(PyUnicode_AS_UNICODE(x), PyUnicode_GET_SIZE(x), base); +#endif PyErr_SetString(PyExc_TypeError, "int() can't convert non-string with explicit base"); return NULL; Index: Objects/longobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v retrieving revision 1.90 diff -u -r1.90 longobject.c --- Objects/longobject.c 2001/08/02 04:15:00 1.90 +++ Objects/longobject.c 2001/08/02 05:55:51 @@ -971,6 +971,7 @@ return NULL; } +#ifdef Py_USING_UNICODE PyObject * PyLong_FromUnicode(Py_UNICODE *u, int length, int base) { @@ -986,6 +987,7 @@ return PyLong_FromString(buffer, NULL, base); } +#endif /* forward */ static PyLongObject *x_divrem @@ -2048,10 +2050,12 @@ return PyNumber_Long(x); else if (PyString_Check(x)) return PyLong_FromString(PyString_AS_STRING(x), NULL, base); +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(x)) return PyLong_FromUnicode(PyUnicode_AS_UNICODE(x), PyUnicode_GET_SIZE(x), base); +#endif else { PyErr_SetString(PyExc_TypeError, "long() can't convert non-string with explicit base"); Index: Objects/object.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v retrieving revision 2.135 diff -u -r2.135 object.c --- Objects/object.c 2001/08/02 04:15:00 2.135 +++ Objects/object.c 2001/08/02 05:55:51 @@ -246,6 +246,7 @@ res = (*v->ob_type->tp_repr)(v); if (res == NULL) return NULL; +#ifdef Py_USING_UNICODE if (PyUnicode_Check(res)) { PyObject* str; str = PyUnicode_AsUnicodeEscapeString(res); @@ -255,6 +256,7 @@ else return NULL; } +#endif if (!PyString_Check(res)) { PyErr_Format(PyExc_TypeError, "__repr__ returned non-string (type %.200s)", @@ -283,6 +285,7 @@ res = (*v->ob_type->tp_str)(v); if (res == NULL) return NULL; +#ifdef Py_USING_UNICODE if (PyUnicode_Check(res)) { PyObject* str; str = PyUnicode_AsEncodedString(res, NULL, NULL); @@ -292,6 +295,7 @@ else return NULL; } +#endif if (!PyString_Check(res)) { PyErr_Format(PyExc_TypeError, "__str__ returned non-string (type %.200s)", @@ -302,6 +306,7 @@ return res; } +#ifdef Py_USING_UNICODE PyObject * PyObject_Unicode(PyObject *v) { @@ -350,6 +355,7 @@ } return res; } +#endif /* Macro to get the tp_richcompare field of a type if defined */ @@ -523,6 +529,7 @@ return (vv < ww) ? -1 : (vv > ww) ? 1 : 0; } +#ifdef Py_USING_UNICODE /* Special case for Unicode */ if (PyUnicode_Check(v) || PyUnicode_Check(w)) { c = PyUnicode_Compare(v, w); @@ -537,6 +544,7 @@ return -2; PyErr_Clear(); } +#endif /* None is smaller than anything */ if (v == Py_None) @@ -1029,6 +1037,7 @@ { PyTypeObject *tp = v->ob_type; +#ifdef Py_USING_UNICODE /* The Unicode to string conversion is done here because the existing tp_getattro slots expect a string object as name and we wouldn't want to break those. */ @@ -1037,6 +1046,8 @@ if (name == NULL) return NULL; } +#endif + if (!PyString_Check(name)) { PyErr_SetString(PyExc_TypeError, "attribute name must be string"); @@ -1070,6 +1081,7 @@ PyTypeObject *tp = v->ob_type; int err; +#ifdef Py_USING_UNICODE /* The Unicode to string conversion is done here because the existing tp_setattro slots expect a string object as name and we wouldn't want to break those. */ @@ -1078,7 +1090,9 @@ if (name == NULL) return -1; } - else if (!PyString_Check(name)){ + else +#endif + if (!PyString_Check(name)){ PyErr_SetString(PyExc_TypeError, "attribute name must be string"); return -1; Index: Objects/stringobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v retrieving revision 2.122 diff -u -r2.122 stringobject.c --- Objects/stringobject.c 2001/08/02 04:15:00 2.122 +++ Objects/stringobject.c 2001/08/02 05:55:53 @@ -173,8 +173,14 @@ goto onError; } - if (encoding == NULL) + if (encoding == NULL) { +#ifdef Py_USING_UNICODE encoding = PyUnicode_GetDefaultEncoding(); +#else + PyErr_SetString(PyExc_ValueError, "no encoding specified"); + goto onError; +#endif + } /* Decode via the codec registry */ v = PyCodec_Decode(str, encoding, errors); @@ -197,6 +203,7 @@ if (v == NULL) goto onError; +#ifdef Py_USING_UNICODE /* Convert Unicode to a string using the default encoding */ if (PyUnicode_Check(v)) { PyObject *temp = v; @@ -205,6 +212,7 @@ if (v == NULL) goto onError; } +#endif if (!PyString_Check(v)) { PyErr_Format(PyExc_TypeError, "decoder did not return a string object (type=%.400s)", @@ -245,8 +253,14 @@ goto onError; } - if (encoding == NULL) + if (encoding == NULL) { +#ifdef Py_USING_UNICODE encoding = PyUnicode_GetDefaultEncoding(); +#else + PyErr_SetString(PyExc_ValueError, "no encoding specified"); + goto onError; +#endif + } /* Encode via the codec registry */ v = PyCodec_Encode(str, encoding, errors); @@ -269,6 +283,7 @@ if (v == NULL) goto onError; +#ifdef Py_USING_UNICODE /* Convert Unicode to a string using the default encoding */ if (PyUnicode_Check(v)) { PyObject *temp = v; @@ -277,6 +292,7 @@ if (v == NULL) goto onError; } +#endif if (!PyString_Check(v)) { PyErr_Format(PyExc_TypeError, "encoder did not return a string object (type=%.400s)", @@ -344,12 +360,15 @@ } if (!PyString_Check(obj)) { +#ifdef Py_USING_UNICODE if (PyUnicode_Check(obj)) { obj = _PyUnicode_AsDefaultEncodedString(obj, NULL); if (obj == NULL) return -1; } - else { + else +#endif + { PyErr_Format(PyExc_TypeError, "expected string or Unicode object, " "%.200s found", obj->ob_type->tp_name); @@ -477,8 +496,10 @@ register unsigned int size; register PyStringObject *op; if (!PyString_Check(bb)) { +#ifdef Py_USING_UNICODE if (PyUnicode_Check(bb)) return PyUnicode_Concat((PyObject *)a, bb); +#endif PyErr_Format(PyExc_TypeError, "cannot add type \"%.200s\" to string", bb->ob_type->tp_name); @@ -586,8 +607,10 @@ { register char *s, *end; register char c; +#ifdef Py_USING_UNICODE if (PyUnicode_Check(el)) return PyUnicode_Contains(a, el); +#endif if (!PyString_Check(el) || PyString_Size(el) != 1) { PyErr_SetString(PyExc_TypeError, "'in ' requires character as left operand"); @@ -868,8 +891,10 @@ sub = PyString_AS_STRING(subobj); n = PyString_GET_SIZE(subobj); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(subobj)) return PyUnicode_Split((PyObject *)self, subobj, maxsplit); +#endif else if (PyObject_AsCharBuffer(subobj, &sub, &n)) return NULL; if (n == 0) { @@ -972,6 +997,7 @@ const size_t old_sz = sz; item = PySequence_Fast_GET_ITEM(seq, i); if (!PyString_Check(item)){ +#ifdef Py_USING_UNICODE if (PyUnicode_Check(item)) { /* Defer to Unicode join. * CAUTION: There's no gurantee that the @@ -983,6 +1009,7 @@ Py_DECREF(seq); return result; } +#endif PyErr_Format(PyExc_TypeError, "sequence item %i: expected string," " %.80s found", @@ -1059,8 +1086,10 @@ sub = PyString_AS_STRING(subobj); n = PyString_GET_SIZE(subobj); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(subobj)) return PyUnicode_Find((PyObject *)self, subobj, i, last, 1); +#endif else if (PyObject_AsCharBuffer(subobj, &sub, &n)) return -2; @@ -1405,6 +1434,7 @@ sub = PyString_AS_STRING(subobj); n = PyString_GET_SIZE(subobj); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(subobj)) { int count; count = PyUnicode_Count((PyObject *)self, subobj, i, last); @@ -1413,6 +1443,7 @@ else return PyInt_FromLong((long) count); } +#endif else if (PyObject_AsCharBuffer(subobj, &sub, &n)) return NULL; @@ -1507,6 +1538,7 @@ table1 = PyString_AS_STRING(tableobj); tablen = PyString_GET_SIZE(tableobj); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(tableobj)) { /* Unicode .translate() does not support the deletechars parameter; instead a mapping to None will cause characters @@ -1518,6 +1550,7 @@ } return PyUnicode_Translate((PyObject *)self, tableobj, NULL); } +#endif else if (PyObject_AsCharBuffer(tableobj, &table1, &tablen)) return NULL; @@ -1526,11 +1559,13 @@ del_table = PyString_AS_STRING(delobj); dellen = PyString_GET_SIZE(delobj); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(delobj)) { PyErr_SetString(PyExc_TypeError, "deletions are implemented differently for unicode"); return NULL; } +#endif else if (PyObject_AsCharBuffer(delobj, &del_table, &dellen)) return NULL; @@ -1755,9 +1790,11 @@ sub = PyString_AS_STRING(subobj); sub_len = PyString_GET_SIZE(subobj); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(subobj)) return PyUnicode_Replace((PyObject *)self, subobj, replobj, count); +#endif else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len)) return NULL; @@ -1765,9 +1802,11 @@ repl = PyString_AS_STRING(replobj); repl_len = PyString_GET_SIZE(replobj); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(replobj)) return PyUnicode_Replace((PyObject *)self, subobj, replobj, count); +#endif else if (PyObject_AsCharBuffer(replobj, &repl, &repl_len)) return NULL; @@ -1818,6 +1857,7 @@ prefix = PyString_AS_STRING(subobj); plen = PyString_GET_SIZE(subobj); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(subobj)) { int rc; rc = PyUnicode_Tailmatch((PyObject *)self, @@ -1827,6 +1867,7 @@ else return PyInt_FromLong((long) rc); } +#endif else if (PyObject_AsCharBuffer(subobj, &prefix, &plen)) return NULL; @@ -1876,6 +1917,7 @@ suffix = PyString_AS_STRING(subobj); slen = PyString_GET_SIZE(subobj); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(subobj)) { int rc; rc = PyUnicode_Tailmatch((PyObject *)self, @@ -1885,6 +1927,7 @@ else return PyInt_FromLong((long) rc); } +#endif else if (PyObject_AsCharBuffer(subobj, &suffix, &slen)) return NULL; @@ -2923,7 +2966,10 @@ char *fmt, *res; int fmtcnt, rescnt, reslen, arglen, argidx; int args_owned = 0; - PyObject *result, *orig_args, *v, *w; + PyObject *result, *orig_args; +#ifdef Py_USING_UNICODE + PyObject *v, *w; +#endif PyObject *dict = NULL; if (format == NULL || !PyString_Check(format) || args == NULL) { PyErr_BadInternalCall(); @@ -2973,8 +3019,10 @@ int sign; int len; char formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */ +#ifdef Py_USING_UNICODE char *fmt_start = fmt; int argidx_start = argidx; +#endif fmt++; if (*fmt == '(') { @@ -3125,11 +3173,13 @@ break; case 's': case 'r': +#ifdef Py_USING_UNICODE if (PyUnicode_Check(v)) { fmt = fmt_start; argidx = argidx_start; goto unicode; } +#endif if (c == 's') temp = PyObject_Str(v); else @@ -3287,6 +3337,7 @@ _PyString_Resize(&result, reslen - rescnt); return result; +#ifdef Py_USING_UNICODE unicode: if (args_owned) { Py_DECREF(args); @@ -3331,6 +3382,7 @@ Py_DECREF(v); Py_DECREF(args); return w; +#endif /* Py_USING_UNICODE */ error: Py_DECREF(result); Index: Python/bltinmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v retrieving revision 2.222 diff -u -r2.222 bltinmodule.c --- Python/bltinmodule.c 2001/08/02 04:15:00 2.222 +++ Python/bltinmodule.c 2001/08/02 05:55:55 @@ -284,6 +284,7 @@ Return a string of one character with ordinal i; 0 <= i < 256."; +#ifdef Py_USING_UNICODE static PyObject * builtin_unichr(PyObject *self, PyObject *args) { @@ -332,6 +333,7 @@ "unichr(i) -> Unicode character\n\ \n\ Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff."; +#endif static PyObject * @@ -619,11 +621,13 @@ if (!PyArg_ParseTuple(args, "OO|O:getattr", &v, &name, &dflt)) return NULL; +#ifdef Py_USING_UNICODE if (PyUnicode_Check(name)) { name = _PyUnicode_AsDefaultEncodedString(name, NULL); if (name == NULL) return NULL; } +#endif if (!PyString_Check(name)) { PyErr_SetString(PyExc_TypeError, @@ -673,11 +677,13 @@ if (!PyArg_ParseTuple(args, "OO:hasattr", &v, &name)) return NULL; +#ifdef Py_USING_UNICODE if (PyUnicode_Check(name)) { name = _PyUnicode_AsDefaultEncodedString(name, NULL); if (name == NULL) return NULL; } +#endif if (!PyString_Check(name)) { PyErr_SetString(PyExc_TypeError, @@ -1266,12 +1272,14 @@ ord = (long)((unsigned char)*PyString_AS_STRING(obj)); return PyInt_FromLong(ord); } +#ifdef Py_USING_UNICODE } else if (PyUnicode_Check(obj)) { size = PyUnicode_GET_SIZE(obj); if (size == 1) { ord = (long)*PyUnicode_AS_UNICODE(obj); return PyInt_FromLong(ord); } +#endif } else { PyErr_Format(PyExc_TypeError, "ord() expected string of length 1, but " \ @@ -1865,7 +1873,9 @@ {"round", builtin_round, 1, round_doc}, {"setattr", builtin_setattr, 1, setattr_doc}, {"slice", builtin_slice, 1, slice_doc}, +#ifdef Py_USING_UNICODE {"unichr", builtin_unichr, 1, unichr_doc}, +#endif {"vars", builtin_vars, 1, vars_doc}, {"xrange", builtin_xrange, 1, xrange_doc}, {"zip", builtin_zip, 1, zip_doc}, @@ -1927,9 +1937,11 @@ return NULL; if (PyDict_SetItemString(dict, "type", (PyObject *) &PyType_Type) < 0) return NULL; +#ifdef Py_USING_UNICODE if (PyDict_SetItemString(dict, "unicode", (PyObject *) &PyUnicode_Type) < 0) return NULL; +#endif debug = PyInt_FromLong(Py_OptimizeFlag == 0); if (PyDict_SetItemString(dict, "__debug__", debug) < 0) { Py_XDECREF(debug); Index: Python/compile.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v retrieving revision 2.208 diff -u -r2.208 compile.c --- Python/compile.c 2001/07/16 16:53:08 2.208 +++ Python/compile.c 2001/08/02 05:55:57 @@ -520,8 +520,8 @@ static PyCodeObject *icompile(node *, struct compiling *); static PyCodeObject *jcompile(node *, char *, struct compiling *, PyCompilerFlags *); -static PyObject *parsestrplus(node *); -static PyObject *parsestr(char *); +static PyObject *parsestrplus(struct compiling*, node *); +static PyObject *parsestr(struct compiling *, char *); static node *get_rawdocstring(node *); static int get_ref_type(struct compiling *, char *); @@ -1111,7 +1111,7 @@ } static PyObject * -parsestr(char *s) +parsestr(struct compiling *com, char *s) { PyObject *v; size_t len; @@ -1122,11 +1122,19 @@ int first = *s; int quote = first; int rawmode = 0; +#ifdef Py_USING_UNICODE int unicode = 0; +#endif if (isalpha(quote) || quote == '_') { if (quote == 'u' || quote == 'U') { +#ifdef Py_USING_UNICODE quote = *++s; unicode = 1; +#else + com_error(com, PyExc_SyntaxError, + "Unicode literals not supported in this Python"); + return NULL; +#endif } if (quote == 'r' || quote == 'R') { quote = *++s; @@ -1155,6 +1163,7 @@ return NULL; } } +#ifdef Py_USING_UNICODE if (unicode || Py_UnicodeFlag) { if (rawmode) return PyUnicode_DecodeRawUnicodeEscape( @@ -1163,6 +1172,7 @@ return PyUnicode_DecodeUnicodeEscape( s, len, NULL); } +#endif if (rawmode || strchr(s, '\\') == NULL) return PyString_FromStringAndSize(s, len); v = PyString_FromStringAndSize((char *)NULL, len); @@ -1238,16 +1248,16 @@ } static PyObject * -parsestrplus(node *n) +parsestrplus(struct compiling* c, node *n) { PyObject *v; int i; REQ(CHILD(n, 0), STRING); - if ((v = parsestr(STR(CHILD(n, 0)))) != NULL) { + if ((v = parsestr(c, STR(CHILD(n, 0)))) != NULL) { /* String literal concatenation */ for (i = 1; i < NCH(n); i++) { PyObject *s; - s = parsestr(STR(CHILD(n, i))); + s = parsestr(c, STR(CHILD(n, i))); if (s == NULL) goto onError; if (PyString_Check(v) && PyString_Check(s)) { @@ -1255,6 +1265,7 @@ if (v == NULL) goto onError; } +#ifdef Py_USING_UNICODE else { PyObject *temp; temp = PyUnicode_Concat(v, s); @@ -1264,6 +1275,7 @@ Py_DECREF(v); v = temp; } +#endif } } return v; @@ -1445,7 +1457,7 @@ com_push(c, 1); break; case STRING: - v = parsestrplus(n); + v = parsestrplus(c, n); if (v == NULL) { c->c_errors++; i = 255; @@ -2863,7 +2875,7 @@ return i == 0; case STRING: - v = parsestr(STR(n)); + v = parsestr(c, STR(n)); if (v == NULL) { PyErr_Clear(); break; @@ -3257,7 +3269,7 @@ } static PyObject * -get_docstring(node *n) +get_docstring(struct compiling *c, node *n) { /* Don't generate doc-strings if run with -OO */ if (Py_OptimizeFlag > 1) @@ -3265,7 +3277,7 @@ n = get_rawdocstring(n); if (n == NULL) return NULL; - return parsestrplus(n); + return parsestrplus(c, n); } static void @@ -3721,7 +3733,7 @@ int i; PyObject *doc; REQ(n, file_input); /* (NEWLINE | stmt)* ENDMARKER */ - doc = get_docstring(n); + doc = get_docstring(c, n); if (doc != NULL) { int i = com_addconst(c, doc); Py_DECREF(doc); @@ -3746,7 +3758,7 @@ node *ch; REQ(n, funcdef); /* funcdef: 'def' NAME parameters ':' suite */ c->c_name = STR(CHILD(n, 1)); - doc = get_docstring(CHILD(n, 4)); + doc = get_docstring(c, CHILD(n, 4)); if (doc != NULL) { (void) com_addconst(c, doc); Py_DECREF(doc); @@ -3796,7 +3808,7 @@ c->c_name = STR(CHILD(n, 1)); c->c_private = c->c_name; ch = CHILD(n, NCH(n)-1); /* The suite */ - doc = get_docstring(ch); + doc = get_docstring(c, ch); if (doc != NULL) { int i = com_addconst(c, doc); Py_DECREF(doc); Index: Python/getargs.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v retrieving revision 2.61 diff -u -r2.61 getargs.c --- Python/getargs.c 2001/07/30 22:34:24 2.61 +++ Python/getargs.c 2001/08/02 05:55:57 @@ -566,6 +566,7 @@ *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(arg)) { arg = UNICODE_DEFAULT_ENCODING(arg); if (arg == NULL) @@ -574,6 +575,7 @@ *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); } +#endif else { /* any buffer-like object */ char *buf; int count = convertbuffer(arg, p, &buf); @@ -587,6 +589,7 @@ if (PyString_Check(arg)) *p = PyString_AS_STRING(arg); +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(arg)) { arg = UNICODE_DEFAULT_ENCODING(arg); if (arg == NULL) @@ -594,6 +597,7 @@ arg, msgbuf); *p = PyString_AS_STRING(arg); } +#endif else return converterr("string", arg, msgbuf); if ((int)strlen(*p) != PyString_Size(arg)) @@ -616,6 +620,7 @@ *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(arg)) { arg = UNICODE_DEFAULT_ENCODING(arg); if (arg == NULL) @@ -624,6 +629,7 @@ *p = PyString_AS_STRING(arg); *q = PyString_GET_SIZE(arg); } +#endif else { /* any buffer-like object */ char *buf; int count = convertbuffer(arg, p, &buf); @@ -640,6 +646,7 @@ *p = 0; else if (PyString_Check(arg)) *p = PyString_AsString(arg); +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(arg)) { arg = UNICODE_DEFAULT_ENCODING(arg); if (arg == NULL) @@ -647,6 +654,7 @@ arg, msgbuf); *p = PyString_AS_STRING(arg); } +#endif else return converterr("string or None", arg, msgbuf); @@ -675,8 +683,10 @@ /* Get 'e' parameter: the encoding name */ encoding = (const char *)va_arg(*p_va, const char *); +#ifdef Py_USING_UNICODE if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); +#endif /* Get output buffer parameter: 's' (recode all objects via Unicode) or @@ -702,6 +712,7 @@ Py_INCREF(s); } else { +#ifdef Py_USING_UNICODE /* Convert object to Unicode */ u = PyUnicode_FromObject(arg); if (u == NULL) @@ -723,6 +734,9 @@ "(encoder failed to return a string)", arg, msgbuf); } +#else + return converterr("string", arg, msgbuf); +#endif } size = PyString_GET_SIZE(s); @@ -808,6 +822,7 @@ break; } +#ifdef Py_USING_UNICODE case 'u': {/* raw unicode buffer (Py_UNICODE *) */ if (*format == '#') { /* any buffer-like object */ void **p = (void **)va_arg(*p_va, char **); @@ -829,6 +844,7 @@ } break; } +#endif case 'S': { /* string object */ PyObject **p = va_arg(*p_va, PyObject **); @@ -839,6 +855,7 @@ break; } +#ifdef Py_USING_UNICODE case 'U': { /* Unicode object */ PyObject **p = va_arg(*p_va, PyObject **); if (PyUnicode_Check(arg)) @@ -847,6 +864,7 @@ return converterr("unicode", arg, msgbuf); break; } +#endif case 'O': { /* object */ PyTypeObject *type; Index: Python/marshal.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v retrieving revision 1.64 diff -u -r1.64 marshal.c --- Python/marshal.c 2001/06/18 22:08:13 1.64 +++ Python/marshal.c 2001/08/02 05:55:58 @@ -187,6 +187,7 @@ w_long((long)n, p); w_string(PyString_AS_STRING(v), n, p); } +#ifdef Py_USING_UNICODE else if (PyUnicode_Check(v)) { PyObject *utf8; utf8 = PyUnicode_AsUTF8String(v); @@ -201,6 +202,7 @@ w_string(PyString_AS_STRING(utf8), n, p); Py_DECREF(utf8); } +#endif else if (PyTuple_Check(v)) { w_byte(TYPE_TUPLE, p); n = PyTuple_Size(v); @@ -472,6 +474,7 @@ } return v; +#ifdef Py_USING_UNICODE case TYPE_UNICODE: { char *buffer; @@ -494,6 +497,7 @@ PyMem_DEL(buffer); return v; } +#endif case TYPE_TUPLE: n = r_long(p); Index: Python/modsupport.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/modsupport.c,v retrieving revision 2.56 diff -u -r2.56 modsupport.c --- Python/modsupport.c 2001/07/31 13:24:44 2.56 +++ Python/modsupport.c 2001/08/02 05:55:58 @@ -195,6 +195,7 @@ return v; } +#ifdef Py_USING_UNICODE static int _ustrlen(Py_UNICODE *u) { @@ -203,6 +204,7 @@ while (*v != 0) { i++; v++; } return i; } +#endif static PyObject * do_mktuple(char **p_format, va_list *p_va, int endchar, int n) @@ -265,6 +267,7 @@ case 'L': return PyLong_FromLongLong((LONG_LONG)va_arg(*p_va, LONG_LONG)); #endif +#ifdef Py_USING_UNICODE case 'u': { PyObject *v; @@ -287,6 +290,7 @@ } return v; } +#endif case 'f': case 'd': return PyFloat_FromDouble( Index: Python/pythonrun.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v retrieving revision 2.140 diff -u -r2.140 pythonrun.c --- Python/pythonrun.c 2001/08/02 04:15:00 2.140 +++ Python/pythonrun.c 2001/08/02 05:55:59 @@ -125,8 +125,10 @@ /* Init codec registry */ _PyCodecRegistry_Init(); +#ifdef Py_USING_UNICODE /* Init Unicode implementation; relies on the codec registry */ _PyUnicode_Init(); +#endif bimod = _PyBuiltin_Init(); if (bimod == NULL) @@ -205,8 +207,10 @@ /* Disable signal handling */ PyOS_FiniInterrupts(); +#ifdef Py_USING_UNICODE /* Cleanup Unicode implementation */ _PyUnicode_Fini(); +#endif /* Cleanup Codec registry */ _PyCodecRegistry_Fini(); Index: Python/sysmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v retrieving revision 2.90 diff -u -r2.90 sysmodule.c --- Python/sysmodule.c 2001/07/23 13:32:43 2.90 +++ Python/sysmodule.c 2001/08/02 05:55:59 @@ -170,6 +170,7 @@ If it is another kind of object, it will be printed and the system\n\ exit status will be one (i.e., failure)."; +#ifdef Py_USING_UNICODE static PyObject * sys_getdefaultencoding(PyObject *self, PyObject *args) { @@ -200,6 +201,7 @@ "setdefaultencoding(encoding)\n\ \n\ Set the current default string encoding used by the Unicode implementation."; +#endif /* * Cached interned string objects used for calling the profile and @@ -546,8 +548,10 @@ {"exc_info", sys_exc_info, 1, exc_info_doc}, {"excepthook", sys_excepthook, 1, excepthook_doc}, {"exit", sys_exit, 0, exit_doc}, +#ifdef Py_USING_UNICODE {"getdefaultencoding", sys_getdefaultencoding, 1, getdefaultencoding_doc}, +#endif #ifdef HAVE_DLOPEN {"getdlopenflags", sys_getdlopenflags, 1, getdlopenflags_doc}, @@ -569,8 +573,10 @@ #ifdef USE_MALLOPT {"mdebug", sys_mdebug, 1}, #endif +#ifdef Py_USING_UNICODE {"setdefaultencoding", sys_setdefaultencoding, 1, setdefaultencoding_doc}, +#endif {"setcheckinterval", sys_setcheckinterval, 1, setcheckinterval_doc}, #ifdef HAVE_DLOPEN @@ -798,9 +804,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);