summaryrefslogtreecommitdiff
path: root/Lib/textwrap.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2012-05-20 10:42:17 +0200
committerMartin v. Löwis <martin@v.loewis.de>2012-05-20 10:42:17 +0200
commited11a5d018e3fc234d7126832756a15c1af67d22 (patch)
tree4f5ee76e85299c314f1e923db480f3733bf48313 /Lib/textwrap.py
parent77e77a12731ad937e6567a2c0dea7dc51c80c69a (diff)
downloadcpython-git-ed11a5d018e3fc234d7126832756a15c1af67d22.tar.gz
Issue #8767: Restore building with --disable-unicode.
Original patch by Stefano Taschini.
Diffstat (limited to 'Lib/textwrap.py')
-rw-r--r--Lib/textwrap.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/textwrap.py b/Lib/textwrap.py
index 9582a1c02f..62ea0b48e6 100644
--- a/Lib/textwrap.py
+++ b/Lib/textwrap.py
@@ -9,6 +9,14 @@ __revision__ = "$Id$"
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.
@@ -147,7 +155,7 @@ class TextWrapper:
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
@@ -167,7 +175,7 @@ class TextWrapper:
'use', ' ', 'the', ' ', '-b', ' ', option!'
otherwise.
"""
- if isinstance(text, unicode):
+ if isinstance(text, _unicode):
if self.break_on_hyphens:
pat = self.wordsep_re_uni
else: