marshal bug?

David wizzardx at gmail.com
Fri Sep 28 03:11:58 EDT 2007


On 9/28/07, Anurag <anuraguniyal at gmail.com> wrote:
> I have been chasing a problem in my code since hours and it bolis down
> to this
> import marshal
> marshal.dumps(str(123)) != marshal.dumps(str("123"))
>

I'm not sure why, but marshal does dump the 2 differently. ie:

>>> marshal.dumps(str(123))
's\x03\x00\x00\x00123'

>>> marshal.dumps(str("123"))
't\x03\x00\x00\x00123'

Somehow, marshal detects a difference between these 2 and changes the
first character in it's output. From the documentation:

"Details of the format are undocumented on purpose; it may change
between Python versions (although it rarely does)".

So you could check the C code to find out what the "s" and "t" mean,
but your assumptions on the format for your app could become incorrect
with new Python versions, or with different marshalling backends.



More information about the Python-list mailing list