[Python-Dev] Re: Multibyte repr() (original) (raw)

Guido van Rossum guido@python.org
Thu, 10 Oct 2002 20:04:05 -0400


> I tried this, and I could not find any problems with the resulting > pickle. The pickle looks like this: > > "S'\x83\\'\np0\n." > > I couldn't get this to fail loading in Python 2.1, 2.2 or 2.3 (CVS); > I tried both pickle and cPickle.

May be you tried with ascii or latin-1 locale. But with Japanese ShiftJIS encoding, you'll see the traceback on unpickling. I tried CVS version of python on Japanese edition of Win2000, I got: Traceback (most recent call last): File "", line 1, in ? File "C:\cygwin\home\ishimoto\wk\python\dist\src\lib\pickle.py", line 1071, in loads return Unpickler(file).load() File "C:\cygwin\home\ishimoto\wk\python\dist\src\lib\pickle.py", line 675, in load dispatchkey File "C:\cygwin\home\ishimoto\wk\python\dist\src\lib\pickle.py", line 754, in loadstring self.append(rep.decode("string-escape")) ValueError: Trailing \ in string

Oops. It looks like this is the nail in the coffin of the locale-specific repr(): a multibyte "character" may end in a backslash that is not escaped.

Martin, I'm afraid there's nothing we can do except revert your multibyte character checkins...

--Guido van Rossum (home page: http://www.python.org/~guido/)