[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Ethan Furman added the comment: Thanks, Larry. I'll have one more patch which will be much better comments in the code, and a small doc enhancement. When it's ready should I reopen this issue or create a new one? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Larry Hastings added the comment: This issue is okay, but it helps my workflow if you'd create a new 3.4 cherry-pick revision for me when it's ready. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Ethan Furman added the comment: Discussion started on PyDev. While working on that I realized/remembered that the main reason to get this in now is that without it a user *cannot* change how pickling works -- (s)he can write the methods, but they will be ignored. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Larry Hastings added the comment: Okay, I'm accepting this. I really just wanted to get more eyes on it, and I'm happy to see that python-dev was pretty unanimous. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Changes by Larry Hastings la...@hastings.org: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Eli Bendersky added the comment: I left some comments in #20653 As for cherry-picking this into 3.4, I'm not sure. Ethan - what is the worst scenario this patch enables to overcome? Someone getting locked in to by-value pickling with certain enums in 3.4? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Ethan Furman added the comment: When I implemented pickle support I did not have a complete understanding of the pickle protocols nor how to best use them. As a result, I picked __getnewargs__ and only supported protocols 2 and 3 (4 didn't exist yet). Serhiy came along and explained a bunch of it to me, so now I know that __reduce_ex__ is the best choice [1] as it supports all the protocol levels, and is always used. The patch removes __getnewargs__ and makes __reduce_ex__ The One Obvious Way, but if it does not go in to 3.4.0 then I won't be able to remove it because of backwards compatibility. [1] Due to what I consider a bug in pickle (still need to create an issue for it, I think) if: class BaseClass: def __reduce_ex__(self, proto): return some_tuple class SubClass(BaseClass): def __reduce__(self): return a_different_tuple huh = SubClass() pickle.dumps(huh) the dumps call will use BaseClass.__reduce_ex__ and not SubClass.__reduce__. For this reason Enum uses __reduce_ex__. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Changes by Ethan Furman et...@stoneleaf.us: -- Removed message: http://bugs.python.org/msg211739 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Ethan Furman added the comment: When I implemented pickle support I did not have a complete understanding of the pickle protocols nor how to best use them. As a result, I picked __getnewargs__ and only supported protocols 2 and 3 (4 didn't exist yet). Serhiy came along and explained a bunch of it to me, so now I know that __reduce_ex__ is the best choice as it supports all the protocol levels, and is always used [1]. The patch removes __getnewargs__ and makes __reduce_ex__ The One Obvious Way, but if it does not go in to 3.4.0 then I won't be able to remove __getnewargs__ because of backwards compatibility. All the tests still pass, and the new test for subclassing to pickle by name passes. [1] pickle supports two low-level methods: __reduce__ and __reduce_ex__; __reduce_ex__ is more powerful and is the preferred method. If a mix-in class to Enum defines __reduce_ex__ and Enum only defines __reduce__, Enum's __reduce__ will not be called. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Ethan Furman added the comment: Larry, If I make changes to the patch, should I reverse the original and then commit one new one so you only have one to merge in, or do you mind having two to do? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Eli Bendersky added the comment: The discussion in #20653 is ongoing but I have to say I don't feel confident about this issue at all. If anything, I'd prefer to explicitly mark advanced pickling support for enums as provisional in 3.4 - this is a simple documentation fix Larry should have no qualms accepting into the RC. We can say that unless folks do funky things, pickling enums should work. But as for support for defining all kinds of strange custom pickling behaviors, this is not supported at this point. I think we all need some time to think about the interaction of enums with pickling and properly document all the scenarios we want, and - more importantly - don't want to support. Enum internals are too complex. Interaction with pickles is even trickier. We don't have to make these decisions in a rush right now. In short, I'm -1 on cherry picking, with +1 on putting provisional disclaimers in strategic places within the enum doc to save us from backwards compatibility worries in this domain for the upcoming cycle. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Ethan Furman added the comment: Can we do that? If a doc change can make it so we're not locked in to supporting __getnewargs__ I could live with that. Although, to be honest, I'd rather get the change in *and* have a doc warning that pickling specifics are subject to change in 3.5. Really, getting rid of __getnewargs__ and going with just __reduce_ex__ is a change that started in issue20534, but at that point I still didn't totally grok __reduce_ex__ et al and so didn't complete the change there. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Larry Hastings added the comment: If you've committed something already, and want to change it, then please request both revisions be cherry-picked. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Larry Hastings added the comment: We still have a couple of weeks left. Ethan, can you start a discussion in python-dev about cherry-picking this for 3.4? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Serhiy Storchaka added the comment: Besides insignificant style nitpick (if classdict.get('__reduce_ex__') is None can be written as if '__reduce_ex__' not in classdict) the patch LGTM at first glance. I'm not very familiar with Enum's complicated machinery and don't sure that no bugs left here (I'm not sure that we should sabotage pickling at all, other types have no such paranoid guard), but at least I'm sure this patch doesn't make things worse. On other hand, this doesn't look as critical bugfix and may be can wait for 3.4.1. Ethan's, Eli's and Barry's opinions have more weight in this matter. -- nosy: +barry, eli.bendersky, serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
New submission from Ethan Furman: 587fd4b91120: Better pickle support for Enum subclasses. -- assignee: larry messages: 211552 nosy: ethan.furman, larry priority: release blocker severity: normal stage: commit review status: open title: 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior type: behavior versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20679] 3.4 cherry-pick: 587fd4b91120 improve Enum subclass behavior
Larry Hastings added the comment: I'd like a second opinion about this before it goes in, just due to the size of the patch. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20679 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com