[Python-Dev] Pickling failure on Enums

Guido van Rossum guido at python.org
Tue May 14 22:58:45 CEST 2013


On Tue, May 14, 2013 at 1:09 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> On 05/13/2013 11:32 AM, Guido van Rossum wrote:
>>
>>
>> But now you enter a different phase of your project, or one of your
>> collaborators does, or perhaps you've released your code on PyPI and one of
>> your users does.  So someone tries to pickle some class instance that
>> happens to contain an unpicklable enum.  That's not a great experience.
>> Pickling and unpickling errors are often remarkably hard to debug.
>> (Especially the latter, so I have privately admonished Ethan to ensure that
>> if the getframe hack doesn't work, the pickle failure should happen at
>> pickling time, not at unpickle time.)
>
>
> I can get pickle failure on members created using the functional syntax with
> no module set;

That's the case I care most about.

> 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.

> I cannot
> get pickle failure on class syntax enums that inherit complex types (such as
> the NEI class in the tests).

Is the NEI base class picklable?

> If anybody has any insight on how to make that work, I'm all ears.

I'm not 100% sure I know what "that" refers to here.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list