Issue #8767: Restore building with --disable-unicode.
Original patch by Stefano Taschini.
diff --git a/Lib/locale.py b/Lib/locale.py
index 0f60dcc..7ddfdb7 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -18,6 +18,14 @@
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.
@@ -353,7 +361,7 @@
"""
# 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: