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 jaraco
Recipients alexandre.vassalotti, belopolsky, georg.brandl, hagen, jaraco, july, ncoghlan
Date 2011-07-25.17:38:01
SpamBayes Score 0.0
Marked as misclassified No
Message-id <1311615483.28.0.386935970652.issue6477@psf.upfronthosting.co.za>
In-reply-to
Content
I've encountered a use-case where the need to pickle NoneType is more relevant (and difficult to work around).

We have a strongly-type Limited Python language, LimPy, which is based on Python (https://bitbucket.org/yougov/limpy). This parser takes, as part of its initialization arguments, a type specification (indicating which types are allowed and not allowed). In some cases, the return value may be `None`, in which case the specification says the type must be `NoneType`.

We're attempting to run this parser in a separate process, using the multiprocessing module, which requires that the arguments passed to and from the parser be pickleable. Unfortunately, because `NoneType` is in the type specification, it cannot be passed to the parser.

Here's an example of one such type specification (from the test suite):

    class SomeFunctionNamespace:
        @signature([IListType], [], None, ListOfInt)
        def listcount(self, l):
            return range(len(l))

        @signature([IListType], [], None, int)
        def listlen(self, l):
            return len(l)

        # ...

        @signature([IIntType], [IStringType], IStringType, NoneType)
        def givespec(self, *args):
            for a in args:
                print a


Note that we can pickle `str` and `int` just fine. Only type(None) fails.

It would be possible to re-write the entire LimPy system (and its child projects) to use a different object where currently NoneType is used, though NoneType is precisely the right thing to be used here except that it can't be pickled.

Since type(None) is a fundamental Python type, it strikes me as a bug that it's not pickleable, though I concede that it's also reasonable to interpret this issue as a feature request (as it's never been pickleable).

Nick makes some good comments that pickling of NoneType should be done right, but other than that, there haven't been any reasons why in principle NoneType should not be pickleable.

NoneType is more akin to `str` and `int` which are pickleable than it is to a function or type(NotImplemented), and this is evident by the way that LimPy uses it (before there was any consideration for pickleability).

Therefore, I propose we reconsider that NoneType should be made pickleable.
History
Date User Action Args
2011-07-25 17:38:03jaracosetrecipients: + jaraco, georg.brandl, ncoghlan, belopolsky, alexandre.vassalotti, hagen, july
2011-07-25 17:38:03jaracosetmessageid: <1311615483.28.0.386935970652.issue6477@psf.upfronthosting.co.za>
2011-07-25 17:38:02jaracolinkissue6477 messages
2011-07-25 17:38:01jaracocreate