[Python-Dev] Pickling failure on Enums
Guido van Rossum
guido at python.org
Tue May 14 23:35:29 CEST 2013
On Tue, May 14, 2013 at 2:13 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 05/14/2013 01:58 PM, Guido van Rossum wrote:
>> On Tue, May 14, 2013 at 1:09 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
>>> I can get pickle failure on members created using the functional syntax
>>> with no module set;
>> That's the case I care most about.
> Good, 'cause that one is handled. :)
Then we're good.
>>> I cannot get pickle failure on those same classes;
>> I suppose you mean "if you create the same enums using class syntax"?
>> Sounds fine to me.
> No. Example class:
> --> Example = Enum('Example', 'example ie eg') # no module name given,
> frame hack fails
> --> pickle(Example.ie)
> # blows up
> --# pickle(Example)
> # succeeds here, but unpickle will fail
Not great, but (a) few people pickle classes, and (b) there's probably
something you can do to the metaclass to sabotage this. But it's fine
to punt on this now.
>>> I cannot get pickle failure on class syntax enums that inherit complex
>>> (such as the NEI class in the tests).
>> Is the NEI base class picklable?
> No. If it is, then the derived enum is also picklable (at least the
> variation I have tested, which is when the NEI base class has
> I'm really hoping you'll say that can be a documentation issue. ;)
Essentially the same response -- with enough hackery you can probably
get this to do what you want, but I wouldn't hold up a release for it.
For example you could file low-priority bugs for both issues in the
hope that someone else figures it out.
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev