summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-09-21 19:22:34 (GMT)
committerGuido van Rossum <guido@python.org>2001-09-21 19:22:34 (GMT)
commitdbb718fa8775731666bb9cbc73662fadee41ea8f (patch)
tree9081dce67bff0bca69fe2eed9e6e832126edd77e /Lib/pickle.py
parent11310bf867ae1c26d2ad9dc696bf2331709b9843 (diff)
downloadcpython-dbb718fa8775731666bb9cbc73662fadee41ea8f.zip
cpython-dbb718fa8775731666bb9cbc73662fadee41ea8f.tar.gz
cpython-dbb718fa8775731666bb9cbc73662fadee41ea8f.tar.bz2
Make these modules work when Python is compiled without Unicode support.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index d5773e2..9b59de8 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -54,6 +54,12 @@ try:
except ImportError:
PyStringMap = None
+try:
+ UnicodeType
+except NameError:
+ UnicodeType = None
+
+
MARK = '('
STOP = '.'
POP = '0'
@@ -304,8 +310,8 @@ class Pickler:
s = mdumps(l)[1:]
self.write(BINUNICODE + s + encoding)
else:
- object = object.replace(u"\\", u"\\u005c")
- object = object.replace(u"\n", u"\\u000a")
+ object = object.replace("\\", "\\u005c")
+ object = object.replace("\n", "\\u000a")
self.write(UNICODE + object.encode('raw-unicode-escape') + '\n')
memo_len = len(memo)
@@ -334,8 +340,8 @@ class Pickler:
self.write(BINSTRING + s + object)
else:
if unicode:
- object = object.replace(u"\\", u"\\u005c")
- object = object.replace(u"\n", u"\\u000a")
+ object = object.replace("\\", "\\u005c")
+ object = object.replace("\n", "\\u000a")
object = object.encode('raw-unicode-escape')
self.write(UNICODE + object + '\n')
else: