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.

Author alexandre.vassalotti
Recipients alexandre.vassalotti, georg.brandl, hagen, july, ncoghlan
Date 2009-07-17.22:58:44
SpamBayes Score 2.4960862e-06
Marked as misclassified No
Message-id <1247871526.85.0.217019057294.issue6477@psf.upfronthosting.co.za>
In-reply-to
Content
I agree with Nick.

And if you really want to, you could hack a Pickler subclass to support
NoneType:

import io
import pickle

class XPickler(pickle.Pickler):
  def persistent_id(self, obj):
    if obj is type(None):
      return "NoneType"
    return None

class XUnpickler(pickle.Unpickler):
  def persistent_load(self, persistent_id):
    if persistent_id == "NoneType":
      return type(None)

def dumps(obj):
    f = io.BytesIO()
    XPickler(f).dump(obj)
    return f.getvalue()

def loads(s):
    return XUnpickler(io.BytesIO(s)).load()

Not super elegant, but it works:

>>> loads(dumps([type(None), None]))
[<type 'NoneType'>, None]
History
Date User Action Args
2009-07-17 22:58:46alexandre.vassalottisetrecipients: + alexandre.vassalotti, georg.brandl, ncoghlan, hagen, july
2009-07-17 22:58:46alexandre.vassalottisetmessageid: <1247871526.85.0.217019057294.issue6477@psf.upfronthosting.co.za>
2009-07-17 22:58:45alexandre.vassalottilinkissue6477 messages
2009-07-17 22:58:44alexandre.vassalotticreate