Recently, "Fredrik Lundh" <fredrik@pythonware.com> said: > on the other hand, I think something is missing from > the buffer design; I definitely don't like that people > can write and marshal objects that happen to > implement the buffer interface, only to find that > Python didn't do what they expected... > > >>> import unicode > >>> import marshal > >>> u = unicode.unicode > >>> s = u("foo") > >>> data = marshal.dumps(s) > >>> marshal.loads(data) > 'f\000o\000o\000' > >>> type(marshal.loads(data)) > <type 'string'> Hmm. Looking at the code there is a catchall at the end, with a comment explicitly saying "Write unknown buffer-style objects as a string". IMHO this is an incorrect design, but that's a bit philosophical (so I'll gladly defer to Our Great Philosopher if he has anything to say on the matter:-). Unless, of course, there are buffer-style non-string objects around that are better read back as strings than not read back at all. Hmm again, I think I'd like it better if marshal.dumps() would barf on attempts to write unrepresentable data. Currently unrepresentable objects are written as TYPE_UNKNOWN (unless they have bufferness (or should I call that "a buffer-aspect"? :-)), which means you think you are writing correctly marshalled data but you'll be in for an exception when you try to read it back... -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4