[ python-Bugs-939395 ] cPickle.Pickler: in list mode, no way to set protocol

SourceForge.net noreply at sourceforge.net
Wed Apr 21 13:02:23 EDT 2004


Bugs item #939395, was opened at 2004-04-22 01:14
Message generated for change (Settings changed) made by jbelmonte
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=939395&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: John Belmonte (jbelmonte)
Assigned to: Nobody/Anonymous (nobody)
>Summary: cPickle.Pickler: in list mode, no way to set protocol

Initial Comment:
cPickle.Pickler may be called without arguments, which
makes a special "list-based" pickler, allowing pickling
to a string.  However, there is no way to set the
protocol in this mode.

Either the Pickler initializer should support keywords
(reported in separate bug), allowing
"Pickler(proto=2)", or the list mode should also be
triggered when the file argument is None, allowing
"Pickler(None, 2)".


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

Comment By: Tim Peters (tim_one)
Date: 2004-04-22 01:46

Message:
Logged In: YES 
user_id=31435

This is undocumented, hence unsupported.  pickle.py doesn't 
allow it either.  So any enhancement first requires a debate 
about whether this should be a supported use (and, if it is, 
pickle.py needs to be changed to match it).  Before then, any 
use of this is at-your-own-risk.

In the meantime, you *can* set the protocol in this 
undocumented mode:

>>> import cPickle
>>> p = cPickle.Pickler(2)
>>>

Works fine.  The constructor does undocumented type-
sniffing on its argument to determine whether it was passed 
an integer (which is taken to be a protocol argument), or not 
(then it's taken to be a file-like object).

There's no claim here that this doesn't all suck, but since it's 
all undocumented and unsupported, it's allowed to suck 
<wink>.

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

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



More information about the Python-bugs-list mailing list