Roundup Robot added the comment:
New changeset 010723a7bd25 by Ethan Furman in branch '3.4':
Close issue20653: allow Enum subclasses to override __reduce_ex__
http://hg.python.org/cpython/rev/010723a7bd25
New changeset 737f2be5e80c by Ethan Furman in branch '3.4':
Close issue20653: improve
Roundup Robot added the comment:
New changeset b637064cc696 by Ethan Furman in branch 'default':
Close issue20653: improve functional API docs; minor code changes
http://hg.python.org/cpython/rev/b637064cc696
--
resolution: - fixed
stage: commit review - committed/rejected
status: open
Roundup Robot added the comment:
New changeset 54ab95407288 by Ethan Furman in branch 'default':
Issue20653: fix ReST for Enum
http://hg.python.org/cpython/rev/54ab95407288
--
___
Python tracker rep...@bugs.python.org
Eli Bendersky added the comment:
Can you upload the new patch?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20653
___
___
Python-bugs-list
Changes by Ethan Furman et...@stoneleaf.us:
Added file: http://bugs.python.org/file34185/issue20653.stoneleaf.03.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20653
___
Changes by Ethan Furman et...@stoneleaf.us:
Added file: http://bugs.python.org/file34191/issue20653.stoneleaf.04.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20653
___
Antoine Pitrou added the comment:
__reduce_ex__ is not the preferred method: it's only necessary if you want so
special-case according to the prototocol number.
In most cases, this is not necessary so it is simpler to define __reduce__ and
not __reduce_ex__.
So I think the patch really should
Ethan Furman added the comment:
Many comments, Eli's and Serhey's code changes incorporated.
--
Added file: http://bugs.python.org/file34173/issue20653.stoneleaf.02.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20653
Ethan Furman added the comment:
Antoine,
If the mixed-in class defines __reduce_ex__, and the Enum class defines
__reduce__, pickle will see that the Enum class has both, and will call the
_ex__ method. It is, therefore, the preferred method (at least by pickle,
which is what we are
Antoine Pitrou added the comment:
If the mixed-in class defines __reduce_ex__, and the Enum class
defines __reduce__, pickle will see that the Enum class has both, and
will call the _ex__ method.
Ah, I understand your concern. You are using preferred in a different
sense. The pickle docs
Ethan Furman added the comment:
Yeah, I was confused by that when I first read it as well. The 2.7 docs are
even worse in that regard (so there has been some progress :).
--
___
Python tracker rep...@bugs.python.org
Antoine Pitrou added the comment:
Yeah, I was confused by that when I first read it as well. The 2.7
docs are even worse in that regard (so there has been some
progress :).
The docs are actually correct. They may be confusing because the
customization possibilities are more numerous than
Eli Bendersky added the comment:
Many comments, Eli's and Serhey's code changes incorporated.
Looks better, thanks. I left some comments in Rietveld.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20653
Ethan Furman added the comment:
Antoine commented:
--
The pickle docs don't mention __reduce_ex__ as being preferred, as in you
should
use this one, on the contrary.
Are we reading the same docs?
http://docs.python.org/dev/library/pickle.html#object.__reduce_ex__
Antoine Pitrou added the comment:
Antoine commented:
--
The pickle docs don't mention __reduce_ex__ as being preferred, as in you
should
use this one, on the contrary.
Are we reading the same docs?
Are we reading the same comments?
--
Ethan Furman added the comment:
On 02/21/2014 11:26 AM, Antoine Pitrou wrote:
Are we reading the same comments?
LOL, apparently not.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20653
Eli Bendersky added the comment:
Ethan, the patch you committed here seems obscure to me. Why __reduce_ex__ and
not __reduce__? Where are the accompanying documentation changes? Can you
clarify more how the full logic of pickling now works - preferably in comments
withing the code?
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
Ethan Furman added the comment:
More explanation:
__getnewargs__ is not used by pickle protocol 0 and 1; to support those
protocols we need __reduce_ex__. Since __reduce_ex__ works for 0, 1, 2, 3, 4,
... there's no reason to have both __reduce_ex__ *and* __getnewargs__.
--
Eli Bendersky added the comment:
If you were enlightened about how to use the pickle protocols, please explains
this better in the code. Currently the code says:
# check for a supported pickle protocols, and if not present sabotage
+# pickling, since it won't work anyway.
+
Ethan Furman added the comment:
Thanks for your comments, Eli, I'll work on getting better comments in the code.
The qualname comment is partially related to the pickling changes as it's
necessary for protocol 4 (I forgot to put that comment in on the previous
pickling change that addressed
Guido van Rossum added the comment:
For the record I'm against it, but I don't have time to explain until after 3.4
has been released.
--
nosy: +gvanrossum
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20653
Serhiy Storchaka added the comment:
This is sad. Because after a release, change it will be much harder.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20653
___
Guido van Rossum added the comment:
It should not be changed after the release either.
On Tue, Feb 18, 2014 at 11:57 AM, Serhiy Storchaka
rep...@bugs.python.orgwrote:
Serhiy Storchaka added the comment:
This is sad. Because after a release, change it will be much harder.
--
Barry A. Warsaw added the comment:
On Feb 18, 2014, at 07:57 PM, Serhiy Storchaka wrote:
This is sad. Because after a release, change it will be much harder.
OTOH, if default-pickling-by-name could be overridden, so can
default-pickling-by-value.
--
Ethan Furman added the comment:
And it is now possible to override and pickle by name if your custom subclass
so chooses.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20653
___
Ethan Furman added the comment:
Patch allows subclass to override __reduce_ex__, which is useful if a mixed-in
type does not have proper pickle support.
--
Added file: http://bugs.python.org/file34138/issue20653.stoneleaf.01.patch
___
Python tracker
Roundup Robot added the comment:
New changeset 587fd4b91120 by Ethan Furman in branch 'default':
Close issue20653: allow Enum subclasses to override __reduce_ex__
http://hg.python.org/cpython/rev/587fd4b91120
--
nosy: +python-dev
resolution: - fixed
stage: patch review -
Ethan Furman added the comment:
Proposal to switch to pickle by name rejected, but Enum now allows
__reduce_ex__ to be overwridden in subclasses.
--
priority: release blocker - normal
___
Python tracker rep...@bugs.python.org
Serhiy Storchaka added the comment:
Ha! You just has committed a patch which I write right now. Thank you Guido
for your time machine.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20653
Larry Hastings added the comment:
If you want this in 3.4.0, please create a 3.4 cherry-pick issue for it.
Personally I would feel a lot more confident in the change if there was any
evidence of it being reviewed before it was checked in. All I see is a
four-minute window between the patch
Barry A. Warsaw added the comment:
On Feb 17, 2014, at 07:03 AM, Serhiy Storchaka wrote:
Currently enums are pickled by values. It means that if the value of enum is
platform depending, pickling one enum you can unpickle other enum on other
platform.
It's probably a good idea to pickle by
Serhiy Storchaka added the comment:
To pickle by value, the subclass needs only restore current implementation of
__reduce_ex__():
def __reduce_ex__(self, proto):
return self.__class__, (self.value,)
--
___
Python tracker
Ethan Furman added the comment:
I agree that pickling by name is the better solution.
Serhiy, could you explain how the un-pickling works with protocol 4?
--
assignee: - ethan.furman
___
Python tracker rep...@bugs.python.org
Serhiy Storchaka added the comment:
This is new feature of protocol 4 (PEP 3154, section 'Serializing more
lookupable objects'). When __reduce_ex__() returns a string (instead of a
tuple), this is interpreted as the name of a global, and qualnames with dots
are now supported in protocol 4.
Serhiy Storchaka added the comment:
May be a number of tests which test pickling subclasses with or without some
special methods are not needed longer. Fell free to improve my patch if you
want to make all cleanup changes in one commit.
--
___
New submission from Serhiy Storchaka:
Currently enums are pickled by values. It means that if the value of enum is
platform depending, pickling one enum you can unpickle other enum on other
platform.
Here is a patch which makes enum pickling by name. It also get rid of not
needed
37 matches
Mail list logo