]> granicus.if.org Git - python/commitdiff
Build with --disable-unicode again. Fixes #1158607.
authorMartin v. Löwis <martin@v.loewis.de>
Tue, 8 Mar 2005 15:03:08 +0000 (15:03 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Tue, 8 Mar 2005 15:03:08 +0000 (15:03 +0000)
Will backport to 2.4.

Lib/codecs.py
Lib/copy.py
Lib/test/test_support.py
Misc/NEWS
Modules/_codecsmodule.c
Modules/_tkinter.c
setup.py

index b283925e01fa2a608420f8922739f23472530c55..b4103fb6e465ccbccd1b000a74ae1c71b23cbe89 100644 (file)
@@ -720,11 +720,19 @@ def make_encoding_map(decoding_map):
 
 ### error handlers
 
-strict_errors = lookup_error("strict")
-ignore_errors = lookup_error("ignore")
-replace_errors = lookup_error("replace")
-xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace")
-backslashreplace_errors = lookup_error("backslashreplace")
+try:
+    strict_errors = lookup_error("strict")
+    ignore_errors = lookup_error("ignore")
+    replace_errors = lookup_error("replace")
+    xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace")
+    backslashreplace_errors = lookup_error("backslashreplace")
+except LookupError:
+    # In --disable-unicode builds, these error handler are missing
+    strict_errors = None
+    ignore_errors = None
+    replace_errors = None
+    xmlcharrefreplace_errors = None
+    backslashreplace_errors = None
 
 # Tell modulefinder that using codecs probably needs the encodings
 # package
index b216beb33642afa3673e9c147834ead480158c86..dbfe2f58a3b18e99c7aa038103d0946b4e85a68f 100644 (file)
@@ -202,12 +202,12 @@ d[float] = _deepcopy_atomic
 d[bool] = _deepcopy_atomic
 try:
     d[complex] = _deepcopy_atomic
-except AttributeError:
+except NameError:
     pass
 d[str] = _deepcopy_atomic
 try:
     d[unicode] = _deepcopy_atomic
-except AttributeError:
+except NameError:
     pass
 try:
     d[types.CodeType] = _deepcopy_atomic
index 485e9e09f6aa4f330af19ad01720f79a61f8da6f..a296caf6d0583916a90d5b771948e4fa006a4bd3 100644 (file)
@@ -144,7 +144,7 @@ else:
             TESTFN_UNICODE_UNENCODEABLE = None
         else:
             # Japanese characters (I think - from bug 846133)
-            TESTFN_UNICODE_UNENCODEABLE = u"@test-\u5171\u6709\u3055\u308c\u308b"
+            TESTFN_UNICODE_UNENCODEABLE = eval('u"@test-\u5171\u6709\u3055\u308c\u308b"')
             try:
                 # XXX - Note - should be using TESTFN_ENCODING here - but for
                 # Windows, "mbcs" currently always operates as if in
index e387e63f5b8bc75b97f11760759b78397a7d0b13..36a21ce3dc496bbcec00c83e5629c2db1b2b0e97 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -221,6 +221,8 @@ Library
 Build
 -----
 
+- Bug #1158607: Build with --disable-unicode again.
+
 - spwdmodule.c is built only if either HAVE_GETSPNAM or HAVE_HAVE_GETSPENT is
   defined.  Discovered as a result of not being able to build on OS X.
 
index ccad827586669e02c1d184bdc06e982d74937c20..a6c42b134bd55a773a8ff2edd394c4da1a47be7b 100644 (file)
@@ -104,8 +104,15 @@ codec_encode(PyObject *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "O|ss:encode", &v, &encoding, &errors))
         return NULL;
 
+#ifdef Py_USING_UNICODE
     if (encoding == NULL)
        encoding = PyUnicode_GetDefaultEncoding();
+#else
+    if (encoding == NULL) {
+       PyErr_SetString(PyExc_ValueError, "no encoding specified");
+       return NULL;
+    }
+#endif
 
     /* Encode via the codec registry */
     v = PyCodec_Encode(v, encoding, errors);
@@ -137,8 +144,15 @@ codec_decode(PyObject *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "O|ss:decode", &v, &encoding, &errors))
         return NULL;
 
+#ifdef Py_USING_UNICODE
     if (encoding == NULL)
        encoding = PyUnicode_GetDefaultEncoding();
+#else
+    if (encoding == NULL) {
+       PyErr_SetString(PyExc_ValueError, "no encoding specified");
+       return NULL;
+    }
+#endif
 
     /* Decode via the codec registry */
     v = PyCodec_Decode(v, encoding, errors);
index 76c2a4485bb9a911bfa61b6802d4e58b7b02c5b2..632f3d6c9a0db16be135a94155abb1efcb38700a 100644 (file)
@@ -838,8 +838,10 @@ static PyGetSetDef PyTclObject_getsetlist[] = {
 };
 
 static PyMethodDef PyTclObject_methods[] = {
+#ifdef Py_USING_UNICODE
        {"__unicode__", (PyCFunction)PyTclObject_unicode, METH_NOARGS,
        PyTclObject_unicode__doc__},
+#endif
        {0}
 };
 
@@ -991,7 +993,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
                        }
                }
 #else
-               res = PyString_FromStringAndSize(value->bytes, value->length);
+               result = PyString_FromStringAndSize(value->bytes, value->length);
 #endif
                return result;
        }
index 85322a853fb31f5ceaa20576c5de23dd9778aaa6..3411643a1dda4ffe0a0dcff4053eeeb1a388014a 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -799,11 +799,12 @@ class PyBuildExt(build_ext):
                               ))
 
         # Hye-Shik Chang's CJKCodecs modules.
-        exts.append(Extension('_multibytecodec',
-                              ['cjkcodecs/multibytecodec.c']))
-        for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'):
-            exts.append(Extension('_codecs_' + loc,
-                                  ['cjkcodecs/_codecs_%s.c' % loc]))
+        if have_unicode:
+            exts.append(Extension('_multibytecodec',
+                                  ['cjkcodecs/multibytecodec.c']))
+            for loc in ('kr', 'jp', 'cn', 'tw', 'hk', 'iso2022'):
+                exts.append(Extension('_codecs_' + loc,
+                                      ['cjkcodecs/_codecs_%s.c' % loc]))
 
         # Dynamic loading module
         if sys.maxint == 0x7fffffff: