]> granicus.if.org Git - python/commitdiff
Fixed bug #1915: Python compiles with --enable-unicode=no again. However several...
authorChristian Heimes <christian@cheimes.de>
Wed, 23 Jan 2008 14:20:41 +0000 (14:20 +0000)
committerChristian Heimes <christian@cheimes.de>
Wed, 23 Jan 2008 14:20:41 +0000 (14:20 +0000)
Lib/encodings/__init__.py
Lib/optparse.py
Misc/NEWS
Parser/tokenizer.c

index 98ae2fae72960bf7692fa04c22f587dcb0148106..b94c374302ec2f1335ed4d6fa07c9cea9ac4878c 100644 (file)
@@ -60,7 +60,7 @@ def normalize_encoding(encoding):
     """
     # Make sure we have an 8-bit string, because .translate() works
     # differently for Unicode strings.
-    if type(encoding) is types.UnicodeType:
+    if hasattr(types, "UnicodeType") and type(encoding) is types.UnicodeType:
         # Note that .encode('latin-1') does *not* use the codec
         # registry, so this call doesn't recurse. (See unicodeobject.c
         # PyUnicode_AsEncodedString() for details)
index 62d2f7e034febdb39eb1b6fa686ddc71abf2a624..4fbe0947e346f43aedad6d75a875c767ede91348 100644 (file)
@@ -824,7 +824,11 @@ except NameError:
     (True, False) = (1, 0)
 
 def isbasestring(x):
-    return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType)
+    try:
+        return isinstance(x, basestring)
+    except:
+        return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType)
+
 
 class Values:
 
index 1fa60b0d8033a0641bb64859b02f2160bc7d0472..eb23c0971ed7e2f7c944ca5b73d9cee64d469d46 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,10 @@ What's New in Python 2.5.2c1?
 Core and builtins
 -----------------
 
+- Bug #1915: Python compiles with --enable-unicode=no again. However
+  several extension methods and modules do not work without unicode
+  support.
+
 - Issue #1678380: distinction between 0.0 and -0.0 was lost during constant
   folding optimization.  This was a regression from Python 2.4.
 
index 1533502c837f24f2b50bc2b7669b8afe12c21afe..f065962f2888301d0d49e50e750382f69173fb09 100644 (file)
@@ -1537,7 +1537,7 @@ PyTokenizer_Get(struct tok_state *tok, char **p_start, char **p_end)
    there, as it must be empty for PGEN, and we can check for PGEN only
    in this file. */
 
-#ifdef PGEN
+#if defined(PGEN) || !defined(Py_USING_UNICODE)
 char*
 PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int* offset)
 {
@@ -1557,7 +1557,6 @@ dec_utf8(const char *enc, const char *text, size_t len) {
        }
        return ret;
 }
-
 char *
 PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int *offset)
 {