[ python-Bugs-1214662 ] test_marshal.py discards marshal.load val

SourceForge.net noreply at sourceforge.net
Sat Jun 4 14:57:19 CEST 2005


Bugs item #1214662, was opened at 2005-06-04 00:52
Message generated for change (Comment added) made by montanaro
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1214662&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Skip Montanaro (montanaro)
Summary: test_marshal.py discards marshal.load val

Initial Comment:
I'm working on making the marshal module work with any file-like 
object.
It's proving a bit more difficult than I imagined it would be.  At any 
rate,
several of the various test_* methods are similar in structure to
test_buffer:

    def test_buffer(self):
        for s in ["", "AndrË Previn", "abc", " "*10000]:
            b = buffer(s)
            new = marshal.loads(marshal.dumps(b))
            self.assertEqual(s, new)
            marshal.dump(b, file(test_support.TESTFN, "wb"))
            marshal.load(file(test_support.TESTFN, "rb"))
            self.assertEqual(s, new)
        os.unlink(test_support.TESTFN)

I'm thinking that throwing away the result of marshal.load has to be 
an
error (especially with the immediately following assert), and that it 
should
really be:

    def test_buffer(self):
        for s in ["", "AndrË Previn", "abc", " "*10000]:
            b = buffer(s)
            new = marshal.loads(marshal.dumps(b))
            self.assertEqual(s, new)
            marshal.dump(b, file(test_support.TESTFN, "wb"))
            new = marshal.load(file(test_support.TESTFN, "rb"))
            self.assertEqual(s, new)
        os.unlink(test_support.TESTFN)

Attached is a patch.  I'd apply it but this apparent mistake is so 
pervasive
that I thought it worth a double-check.

Skip


----------------------------------------------------------------------

>Comment By: Skip Montanaro (montanaro)
Date: 2005-06-04 07:57

Message:
Logged In: YES 
user_id=44345

Agreed about cut-n-paste as the likely culprit.  Fix applied to
test_marshal.py 1.11.

(I did run the tests... ;-)


----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2005-06-04 07:46

Message:
Logged In: YES 
user_id=6656

Makes sense to me.  I guess the pervasiveness has something to do with 
the evils of copy & paste...

(I haven't run the new tests, mind)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1214662&group_id=5470


More information about the Python-bugs-list mailing list