On 05/14/2013 03:16 PM, Nick Coghlan wrote: > > On 15 May 2013 07:38, "Guido van Rossum" <guido at python.org <mailto:guido at python.org>> wrote: >> >> On Tue, May 14, 2013 at 2:13 PM, Ethan Furman <ethan at stoneleaf.us <mailto: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 <mailto: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. > > It may be a bug in pickle - it sounds like it is sanity checking type(obj), but not checking for cases where obj itself > is a class. Well, it's definitely not calling the metaclass' __reduce__ as that's where I put the bomb (hmm, will I be visited by men in dark suits now?) so maybe that's a bug in pickle. At any rate, I figured it out -- give the class' __module__ a dummy name (I like 'uh uh' ;) and when pickle can't find that module it'll blow itself up. -- ~Ethan~
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4