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))
Can someone please tell me why?
when
str(123) == str(123)
or are they different?
it also means that
if s = str(123)
marshal.dumps(s) !=
Anurag 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))
Can someone please tell me why?
when
str(123) == str(123)
or are they different?
it also means that
if s = str(123)
On 9/28/07, Anurag [EMAIL PROTECTED] 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))
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'
I've just checked the source [1].
's' refers to a regular string, 't' refers to an interned[2] string.
In other words the
Thanks for the reply.
It seems problem is due to
Any string in Python can be interned or not, the difference being
how/where the value is stored internally. The marshal module includes
such information in its output. What you are doing is probably
considered a misuse of the marshal module.
En Fri, 28 Sep 2007 04:26:39 -0300, Anurag [EMAIL PROTECTED]
escribi�:
Now is there a easy way to by pass it (hack around it)
I tried various options but all fail e.g.
i= 123; marshal.dumps(%d%123) != marshal.dumps(%d%i)
You can't. Don't use marshal to compare objects. You appear to assume
[1] http://coverage.livinglogic.de/Python/marshal.c.html. (Actually, I
checked the downloaded bz2, but this is the only URL for marshal.c I
could find)
A better URL is
http://svn.python.org/projects/python/trunk/Python/marshal.c
or
http://svn.python.org/view/python/trunk/Python/marshal.c
OK - I think this is it:
My last post fingering pickle was almost but not quite right*. Actually the
cuplrit is marshal, which produces the incorrect result that was noted. The bug
has nothing to do with IDLE, except that it uses marshal for inter-process
communication.
Here's the failure