diff -r 5bad73fbf593 Lib/site.py --- a/Lib/site.py Sun Apr 29 09:25:25 2012 -0700 +++ b/Lib/site.py Mon Apr 30 10:14:56 2012 +0200 @@ -560,7 +560,31 @@ if hasattr(sys, "setdefaultencoding"): del sys.setdefaultencoding -main() +try: + unicode +except NameError: + # If Python is built with no unicode support, we need to patch a + # few modules where unicode is used only in isinstance clauses. + class unicode(object): + def __new__(cls, *args, **kw): + # Make sure that you cannot instantiate instances + raise TypeError("No unicode support") + # We do not want to pollute the __builtin__ names space, so we + # inject this unicode class directly into the modules that need it + def _patch_modules(*modnames): + for n in modnames: + try: + __import__(n) + m = sys.modules[n] + except ImportError: + pass + else: + setattr(m, 'unicode', unicode) + _patch_modules('posixpath', 'glob') + main() + _patch_modules('locale', 'textwrap', 'unittest.case') +else: + main() def _script(): help = """\ diff -r 5bad73fbf593 Lib/test/script_helper.py --- a/Lib/test/script_helper.py Sun Apr 29 09:25:25 2012 -0700 +++ b/Lib/test/script_helper.py Mon Apr 30 10:14:56 2012 +0200 @@ -10,7 +10,10 @@ import py_compile import contextlib import shutil -import zipfile +try: + import zipfile +except: + pass from test.test_support import strip_python_stderr diff -r 5bad73fbf593 Lib/test/test_support.py --- a/Lib/test/test_support.py Sun Apr 29 09:25:25 2012 -0700 +++ b/Lib/test/test_support.py Mon Apr 30 10:14:56 2012 +0200 @@ -405,7 +405,7 @@ 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: