This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Support non-file source/dest in marshal
Type: enhancement Stage: patch review
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, loewis
Priority: normal Keywords: patch

Created on 2005-06-04 17:20 by skip.montanaro, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
marshal.diff skip.montanaro, 2005-06-04 17:20
Messages (4)
msg48426 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2005-06-04 17:20
I own bug #780354.  The problem is that socket.makefile() no
longer returns a true file.  This breaks code that had assumed
it did.  The marshal module is one such instance.

In the above bug's corresponce Martin stated:

    Instead, I think the C modules that expect file objects need
    to be fixed.

Later on Martin stated that he thought it would be fine to simply
document the limitation for the marshal module.  I ignored that
and fixed it in the attached patch.  It includes modified docs and
an updated test suite.

It's obviously somewhat slower than the current version when
reading/writing true files.  That's to be expected.  I wanted to
get it right first.  I imagine something can be done to speed
things up in the common case (run PyFile_Check() and make
calls to stdio functions if it is a true file).

Even if this patch is rejected, the modified test_marshal.py
should probably be kept (with suitable deletions), as it refactors
the individual tests into helper functions, thus avoiding a lot
of code duplication and potential future cut-n-paste errors.
msg48427 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-08-07 21:38
Logged In: YES 
user_id=21627

I think I would prefer if WFILE continued to support FILE*
as a special case, for performance reasons.

Also, since write() will be called really often (once per
byte), it might be worth to speed up the call somewhat:
- look up file.write initially, and store that in WFILE,
instead of storing the object itself. Make sure to DECREF
.write when you are done.
- Call the function through a tuple, to avoid the argument
parsing. You know in advance that there is a single only a
single argument, and that this is a string.

Also, I'm worried about the error handling. If .write()
raises an exception, marshalling should abort, IMO. The
right way would be to add an error code to all w_*
functions, and immediately return when there was an error.
However, just putting the WFILE into an error state (by
setting p->error to 3), and then refusing to perform further
.write calls might be sufficient.
msg110433 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-16 13:14
Unless anyone expresses an interest I belive that this should be closed.
msg110816 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-19 22:24
Closing as noone has responded.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 42053
2010-07-19 22:24:56BreamoreBoysetstatus: pending -> closed
resolution: wont fix
messages: + msg110816
2010-07-16 13:14:42BreamoreBoysetstatus: open -> pending
nosy: + BreamoreBoy
messages: + msg110433

2009-02-16 06:16:12skip.montanarosetnosy: - skip.montanaro
2009-02-16 00:45:48ajaksu2setstage: patch review
type: enhancement
versions: + Python 2.7, - Python 2.5
2005-06-04 17:20:16skip.montanarocreate