Commit ce1b92a9 authored by Christian Heimes's avatar Christian Heimes

Fixed bug #1915: Python compiles with --enable-unicode=no again. However...

Fixed bug #1915: Python compiles with --enable-unicode=no again. However several extension methods and modules do not work without unicode support.
parent 9e55242b
...@@ -30,6 +30,7 @@ Written by Marc-Andre Lemburg (mal@lemburg.com). ...@@ -30,6 +30,7 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
import codecs import codecs
from encodings import aliases from encodings import aliases
import __builtin__
_cache = {} _cache = {}
_unknown = '--unknown--' _unknown = '--unknown--'
...@@ -60,7 +61,7 @@ def normalize_encoding(encoding): ...@@ -60,7 +61,7 @@ def normalize_encoding(encoding):
""" """
# Make sure we have an 8-bit string, because .translate() works # Make sure we have an 8-bit string, because .translate() works
# differently for Unicode strings. # differently for Unicode strings.
if isinstance(encoding, unicode): if hasattr(__builtin__, "unicode") and isinstance(encoding, unicode):
# Note that .encode('latin-1') does *not* use the codec # Note that .encode('latin-1') does *not* use the codec
# registry, so this call doesn't recurse. (See unicodeobject.c # registry, so this call doesn't recurse. (See unicodeobject.c
# PyUnicode_AsEncodedString() for details) # PyUnicode_AsEncodedString() for details)
......
...@@ -824,8 +824,12 @@ except NameError: ...@@ -824,8 +824,12 @@ except NameError:
(True, False) = (1, 0) (True, False) = (1, 0)
def isbasestring(x): def isbasestring(x):
try:
return isinstance(x, basestring)
except:
return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType) return isinstance(x, types.StringType) or isinstance(x, types.UnicodeType)
class Values: class Values:
def __init__(self, defaults=None): def __init__(self, defaults=None):
......
...@@ -12,6 +12,10 @@ What's New in Python 2.6 alpha 1? ...@@ -12,6 +12,10 @@ What's New in Python 2.6 alpha 1?
Core and builtins Core and builtins
----------------- -----------------
- Bug #1915: Python compiles with --enable-unicode=no again. However
several extension methods and modules do not work without unicode
support.
- Patch #1720595: add T_BOOL to the range of structmember types. - Patch #1720595: add T_BOOL to the range of structmember types.
- Issue #1882: when compiling code from a string, encoding cookies in the - Issue #1882: when compiling code from a string, encoding cookies in the
......
...@@ -1563,7 +1563,7 @@ PyTokenizer_Get(struct tok_state *tok, char **p_start, char **p_end) ...@@ -1563,7 +1563,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 there, as it must be empty for PGEN, and we can check for PGEN only
in this file. */ in this file. */
#ifdef PGEN #if defined(PGEN) || !defined(Py_USING_UNICODE)
char* char*
PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int* offset) PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int* offset)
{ {
...@@ -1584,7 +1584,6 @@ dec_utf8(const char *enc, const char *text, size_t len) { ...@@ -1584,7 +1584,6 @@ dec_utf8(const char *enc, const char *text, size_t len) {
} }
return ret; return ret;
} }
char * char *
PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int *offset) PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int *offset)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment