Original patch by Stefano Taschini.
import re
import fnmatch
+try:
+ _unicode = unicode
+except NameError:
+ # If Python is built without Unicode support, the unicode type
+ # will not exist. Fake one.
+ class _unicode(object):
+ pass
+
__all__ = ["glob", "iglob"]
def glob(pathname):
def glob1(dirname, pattern):
if not dirname:
dirname = os.curdir
- if isinstance(pattern, unicode) and not isinstance(dirname, unicode):
+ if isinstance(pattern, _unicode) and not isinstance(dirname, unicode):
dirname = unicode(dirname, sys.getfilesystemencoding() or
sys.getdefaultencoding())
try:
import operator
import functools
+try:
+ _unicode = unicode
+except NameError:
+ # If Python is built without Unicode support, the unicode type
+ # will not exist. Fake one.
+ class _unicode(object):
+ pass
+
# Try importing the _locale module.
#
# If this fails, fall back on a basic 'C' locale emulation.
"""
# Normalize the locale name and extract the encoding
- if isinstance(localename, unicode):
+ if isinstance(localename, _unicode):
localename = localename.encode('ascii')
fullname = localename.translate(_ascii_lower_map)
if ':' in fullname:
import warnings
from genericpath import *
+try:
+ _unicode = unicode
+except NameError:
+ # If Python is built without Unicode support, the unicode type
+ # will not exist. Fake one.
+ class _unicode(object):
+ pass
+
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","getctime","islink","exists","lexists","isdir","isfile",
def normpath(path):
"""Normalize path, eliminating double slashes, etc."""
# Preserve unicode (if path is unicode)
- slash, dot = (u'/', u'.') if isinstance(path, unicode) else ('/', '.')
+ slash, dot = (u'/', u'.') if isinstance(path, _unicode) else ('/', '.')
if path == '':
return dot
initial_slashes = path.startswith('/')
def abspath(path):
"""Return an absolute path."""
if not isabs(path):
- if isinstance(path, unicode):
+ if isinstance(path, _unicode):
cwd = os.getcwdu()
else:
cwd = os.getcwd()
import py_compile
import contextlib
import shutil
-import zipfile
+try:
+ import zipfile
+except ImportError:
+ # If Python is build without Unicode support, importing _io will
+ # fail, which, in turn, means that zipfile cannot be imported
+ # Most of this module can then still be used.
+ pass
from test.test_support import strip_python_stderr
the CWD, an error is raised. If it's True, only a warning is raised
and the original CWD is used.
"""
- if isinstance(name, unicode):
+ if have_unicode and isinstance(name, unicode):
try:
name = name.encode(sys.getfilesystemencoding() or 'ascii')
except UnicodeEncodeError:
import string, re
+try:
+ _unicode = unicode
+except NameError:
+ # If Python is built without Unicode support, the unicode type
+ # will not exist. Fake one.
+ class _unicode(object):
+ pass
+
# Do the right thing with boolean values for all known Python versions
# (so this module can be copied to projects that don't depend on Python
# 2.3, e.g. Optik and Docutils) by uncommenting the block of code below.
if self.replace_whitespace:
if isinstance(text, str):
text = text.translate(self.whitespace_trans)
- elif isinstance(text, unicode):
+ elif isinstance(text, _unicode):
text = text.translate(self.unicode_whitespace_trans)
return text
'use', ' ', 'the', ' ', '-b', ' ', option!'
otherwise.
"""
- if isinstance(text, unicode):
+ if isinstance(text, _unicode):
if self.break_on_hyphens:
pat = self.wordsep_re_uni
else:
self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
self.addTypeEqualityFunc(set, 'assertSetEqual')
self.addTypeEqualityFunc(frozenset, 'assertSetEqual')
- self.addTypeEqualityFunc(unicode, 'assertMultiLineEqual')
+ try:
+ self.addTypeEqualityFunc(unicode, 'assertMultiLineEqual')
+ except NameError:
+ # No unicode support in this build
+ pass
def addTypeEqualityFunc(self, typeobj, function):
"""Add a type specific assertEqual style function to compare a type.
Geoff Talvola
William Tanksley
Christian Tanzer
+Stefano Taschini
Steven Taschuk
Monty Taylor
Amy Taylor
Build
-----
+- Issue #8767: Restore building with --disable-unicode.
+ Patch by Stefano Taschini.
+
- Build against bzip2 1.0.6 and openssl 0.9.8x on Windows.
- Issue #14557: Fix extensions build on HP-UX. Patch by Adi Roiban.
if (PyType_Ready(&PySet_Type) < 0)
Py_FatalError("Can't initialize set type");
+#ifdef Py_USING_UNICODE
if (PyType_Ready(&PyUnicode_Type) < 0)
Py_FatalError("Can't initialize unicode type");
+#endif
if (PyType_Ready(&PySlice_Type) < 0)
Py_FatalError("Can't initialize slice type");
Py_CLEAR(str_newline);
return NULL;
}
+#ifdef Py_USING_UNICODE
unicode_newline = PyUnicode_FromString("\n");
if (unicode_newline == NULL) {
Py_CLEAR(str_newline);
Py_CLEAR(unicode_space);
return NULL;
}
+#endif
}
if (!PyArg_ParseTupleAndKeywords(dummy_args, kwds, "|OOO:print",
kwlist, &sep, &end, &file))
will return a surrogate. In both the cases skip the
optimization in order to produce compatible pycs.
*/
+#ifdef Py_USING_UNICODE
if (newconst != NULL &&
PyUnicode_Check(v) && PyUnicode_Check(newconst)) {
Py_UNICODE ch = PyUnicode_AS_UNICODE(newconst)[0];
return 0;
}
}
+#endif
break;
case BINARY_LSHIFT:
newconst = PyNumber_Lshift(v, w);
$as_echo "#define Py_UNICODE_SIZE 4" >>confdefs.h
;;
+no) ;; # To allow --disable-unicode
*) as_fn_error $? "invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase)." "$LINENO" 5 ;;
esac
ucs4) unicode_size="4"
AC_DEFINE(Py_UNICODE_SIZE,4)
;;
+no) ;; # To allow --disable-unicode
*) AC_MSG_ERROR([invalid value for --enable-unicode. Use either ucs2 or ucs4 (lowercase).]) ;;
esac