summaryrefslogtreecommitdiffstats
path: root/Lib/shlex.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-12-19 02:08:38 (GMT)
committerGuido van Rossum <guido@python.org>2000-12-19 02:08:38 (GMT)
commitfb10c3f6645cab80b95e52ae76297616dcb6ec64 (patch)
treecb84db270d497a2ec516fbef3efc38916d84d52e /Lib/shlex.py
parent8b74b15b9283bea63a194e71b5c88af5dc6f497d (diff)
downloadcpython-fb10c3f6645cab80b95e52ae76297616dcb6ec64.zip
cpython-fb10c3f6645cab80b95e52ae76297616dcb6ec64.tar.gz
cpython-fb10c3f6645cab80b95e52ae76297616dcb6ec64.tar.bz2
Minimal fix for the complaints about pickling Unicode objects. (SF
bugs #126161 and 123634). The solution doesn't use the unicode-escape encoding; that has other problems (it seems not 100% reversible). Rather, it transforms the input Unicode object slightly before encoding it using raw-unicode-escape, so that the decoding will reconstruct the original string: backslash and newline characters are translated into their \uXXXX counterparts. This is backwards incompatible for strings containing backslashes, but for some of those strings, the pickling was already broken. Note that SF bug #123634 complains specifically that cPickle fails to unpickle the pickle for u'' (the empty Unicode string) correctly. This was an off-by-one error in load_unicode(). XXX Ugliness: in order to do the modified raw-unicode-escape, I've cut-and-pasted a copy of PyUnicode_EncodeRawUnicodeEscape() into this file that also encodes '\\' and '\n'. It might be nice to migrate this into the Unicode implementation and give this encoding a new name ('half-raw-unicode-escape'? 'pickle-unicode-escape'?); that would help pickle.py too. But right now I can't be bothered with the necessary infrastructural changes.
Diffstat (limited to 'Lib/shlex.py')
0 files changed, 0 insertions, 0 deletions