Mailing List Archive

[issue2980] Pickle stream for unicode object may contain non-ASCII characters.
Torsten Bronger <bronger@physik.rwth-aachen.de> added the comment:

I ran into this problem today when writing python data structures into a
database. Only ASCII is safe in this situation. I understood the
Python docs that protocol 0 was ASCII-only.

I use pickle+base64 now, however, this makes debugging more difficult.

Anyway, I think that the docs should clearly say that protocol 8 is not
ASCII-only because this is important in the Python world. For example,
I saw this issue because Django makes an implicit unicode() conversion
with my input which fails with non-ASCII.

----------
nosy: +bronger

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue2980>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue2980] Pickle stream for unicode object may contain non-ASCII characters. [ In reply to ]
Torsten Bronger <bronger@physik.rwth-aachen.de> added the comment:

"protocol 8" --> "protocol 0" of course.

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue2980>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue2980] Pickle stream for unicode object may contain non-ASCII characters. [ In reply to ]
Marc-Andre Lemburg <mal@egenix.com> added the comment:

On 2009-01-21 16:43, Torsten Bronger wrote:
> Torsten Bronger <bronger@physik.rwth-aachen.de> added the comment:
>
> I ran into this problem today when writing python data structures into a
> database. Only ASCII is safe in this situation. I understood the
> Python docs that protocol 0 was ASCII-only.
>
> I use pickle+base64 now, however, this makes debugging more difficult.

Databases can handle binary data just fine, so pickle protocol 2
should be better in your situation.

If you require ASCII-only data, you can also use pickle protocol 2,
zlib and base64 to get a compact version of a serialized Python object.

> Anyway, I think that the docs should clearly say that protocol 8 is not
> ASCII-only because this is important in the Python world. For example,
> I saw this issue because Django makes an implicit unicode() conversion
> with my input which fails with non-ASCII.

That sounds like an issue with Django - it shouldn't try to convert
binary data to Unicode (which is reserved for text data).

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue2980>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue2980] Pickle stream for unicode object may contain non-ASCII characters. [ In reply to ]
Torsten Bronger <bronger@physik.rwth-aachen.de> added the comment:

Well, Django doesn't story binary data at all but wants you to store
image files etc in the file system. Whether this was a good design
decision, is beyond the scope of this issue. My points actually are
only these:

a) the docs strongly suggest that protocol 0 is ASCII-only and this
should be clarified (one sentence would be fully sufficient I think)

b) currently, there is no way in the standard lib to serialise data in a
debuggable, ASCII-only format

Probably b) is not important. *I* want to have it currently but this
doesn't mean much.

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue2980>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com