marshal bug?

David wizzardx at
Fri Sep 28 09:11:58 CEST 2007

On 9/28/07, Anurag <anuraguniyal at> 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))

>>> marshal.dumps(str("123"))

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