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.

Title: cPickle.Pickler: in list mode, no way to set protocol
Type: Stage:
Components: Library (Lib) Versions:
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: alexandre.vassalotti, jbelmonte, tim.peters
Priority: normal Keywords:

Created on 2004-04-21 16:14 by jbelmonte, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg20553 - (view) Author: John Belmonte (jbelmonte) * Date: 2004-04-21 16:14
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)".
msg20554 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-04-21 16:46
Logged In: YES 

This is undocumented, hence unsupported. doesn't 
allow it either.  So any enhancement first requires a debate 
about whether this should be a supported use (and, if it is, 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 
msg58058 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2007-12-01 17:44
Please mark this bug as Won't Fix.

As Tim said, the list-based interface of cPickle is unsupported and
pending removal. Please use the pickle.dumps and pickle.loads functions
if you want string interface to pickle.
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40172
2007-12-01 18:15:32georg.brandlsetstatus: open -> closed
resolution: wont fix
2007-12-01 17:44:29alexandre.vassalottisetnosy: + alexandre.vassalotti
messages: + msg58058
2004-04-21 16:14:25jbelmontecreate