Roundup Robot added the comment:
New changeset fae92309c3be by Ethan Furman in branch 'default':
Closes issue 17947. Adds PEP-0435 (Enum, IntEnum) to the stdlib.
http://hg.python.org/cpython/rev/fae92309c3be
--
resolution: - fixed
stage: patch review - committed/rejected
status: open
Nick Coghlan added the comment:
That commit looks just a touch incomplete...
--
resolution: fixed -
stage: committed/rejected - commit review
status: closed - open
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
Eli Bendersky added the comment:
Ethan, did you forget to hg add ?
On Fri, Jun 14, 2013 at 12:44 AM, Nick Coghlan rep...@bugs.python.orgwrote:
Nick Coghlan added the comment:
That commit looks just a touch incomplete...
--
resolution: fixed -
stage: committed/rejected - commit
Ethan Furman added the comment:
Well, that made me laugh first thing in the morning!
I had nuked and redone my clone, and yeah, forgot to re-add the files. :/
Trying again...
Commit message was okay?
--
___
Python tracker rep...@bugs.python.org
Roundup Robot added the comment:
New changeset e7a01c7f69fe by Ethan Furman in branch 'default':
Closes issue 17947. Adds PEP-0435 (Adding an Enum type to the Python standard
library).
http://hg.python.org/cpython/rev/e7a01c7f69fe
--
resolution: - fixed
stage: commit review -
STINNER Victor added the comment:
New changeset e7a01c7f69fe by Ethan Furman in branch 'default':
Closes issue 17947. Adds PEP-0435 (Adding an Enum type to the Python
standard library).
http://hg.python.org/cpython/rev/e7a01c7f69fe
Great job :-)
--
nosy: +haypo
Nick Coghlan added the comment:
Nicely done - you can also mark the PEP as Final now :)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Ethan Furman added the comment:
Final (hopefully! ;) patch.
I stuck the toc reference in datatypes.
If no more edits are necessary I'll commit on Friday (three days from now).
--
Added file: http://bugs.python.org/file30548/pep-0435.12.stoneleaf.patch
Ethan Furman added the comment:
Hopefully the last update. :)
--
Added file: http://bugs.python.org/file30512/pep-0435.11.stoneleaf.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
Eli Bendersky added the comment:
LGTM.
I suggest you wait for a couple of days to see if others have any critical
comments and then commit.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
Zachary Ware added the comment:
enum.rst will need to be added to a table of contents page somewhere, I would
guess possibly Development Tools (Doc/library/development.rst) or maybe Data
Types (Doc/library/datatypes.rst). I would trust almost anybody else's opinion
over mine on where it
Ethan Furman added the comment:
Hopefully the final bit of code, plus docs.
Code changes:
_names_ are reserved
Doc changes (different from the PEP):
examples of AutoEnum, UniqueEnum, and OrderedEnum
--
Added file: http://bugs.python.org/file30504/pep-0435.08.stoneleaf.patch
Changes by Ethan Furman et...@stoneleaf.us:
Removed file: http://bugs.python.org/file30504/pep-0435.08.stoneleaf.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Changes by Ethan Furman et...@stoneleaf.us:
Added file: http://bugs.python.org/file30505/pep-0435.08.stoneleaf.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Changes by Ethan Furman et...@stoneleaf.us:
Removed file: http://bugs.python.org/file30505/pep-0435.08.stoneleaf.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Ethan Furman added the comment:
Apologies for the noise -- was having trouble getting the correct patch
attached. :/
--
Added file: http://bugs.python.org/file30506/pep-0435.09.stoneleaf.patch
___
Python tracker rep...@bugs.python.org
Ethan Furman added the comment:
So, which is better?
To have a @unique class decorator as part of the module, or to have a
UniqueEnum recipe in the docs?
A decorator is immediately usable, but requires remembering an extra line of
code.
An example requires being put into a local utility
Eli Bendersky added the comment:
Nick prudently moved the unique discussion to its own issue - 18042. Let's get
the initial implementation docs committed first (without unique in the
implementation, although it's fine to have it as an example in the docs for
now), close this issue, and then
Ethan Furman added the comment:
Good idea, thanks.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
___
Python-bugs-list mailing list
Eli Bendersky added the comment:
I sent a fresh review - nothing major; it's very near commit readiness now.
Additional changes can be done after the initial commit. We have time until 3.4
beta (November 2013) to tweak stuff (and the documentation whenever...)
--
Ethan Furman added the comment:
Doc updates are in.
I removed the 'unique, constant' from the first line of the intro, as neither
of those things are necessarily true.
--
Added file: http://bugs.python.org/file30511/pep-0435.10.stoneleaf.patch
___
Ethan Furman added the comment:
Hmm -- I was confusing member names with member values; I'll put 'unique' back
in.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Ethan Furman added the comment:
Working on documentation...
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
___
Python-bugs-list
Eli Bendersky added the comment:
I tweaked the code a bit (no functionality changes, mostly cleanups and a bit
of refactoring). Figured it will be easier to just send an updated patch than
another review. The diff from patch 06 can be seen via the Rietveld interface.
Also, after reading the
Ethan Furman added the comment:
Wow. I definitely felt like an apprentice after reading the changes. Thanks,
Eli, that looks worlds better!
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
Eli Bendersky added the comment:
Thanks Ethan :)
From my point of view this is LGTM, as long as:
* There's ReST documentation
* You remove the code to support extensions and customizations not mandated by
PEP 435. As I mentioned before, this seems to be a YAGNI that complicates the
code
Nick Coghlan added the comment:
Supporting extensions was one of the things that got Ethan's version
through review. So -1 on going back on our promise to support those
variants. They have been reviewed and tested just as thoroughly as the rest
of the design.
--
Nick Coghlan added the comment:
Also, we know for a fact that people plan to use the customisation features
- it was making their code work that drove the current extension design.
--
___
Python tracker rep...@bugs.python.org
Eli Bendersky added the comment:
I'm not sure which promises you're referring to Nick, and to whom they were
made; the only formal promise we made is PEP 435 - and it doesn't mention this
extensibility.
I won't argue beyond this comment, since I know I'm part of the minority
opinion here.
Guido van Rossum added the comment:
Eli, what's wrong with having a backdoor? Python is literally *full* of
backdoors. I have a feeling that somehow you are trying to build an Enum class
that is unpythonic in its desire to enforce some kind of ideal enum behavior.
--
Eli Bendersky added the comment:
Guido, IMHO back-doors are fine in many cases, just not this one. The way I see
it, our main goal here is to collect a bunch of custom implementations of enums
under a single umbrella. This is not very different from what was done with
OrderedDict and
Nick Coghlan added the comment:
Eli, remember that TOOWTDI stands for There's one *obvious* way to do it
rather than There's *only* one way to do it. The latter interpretation leads
to insanely complex APIs that attempt to solve everyone's problems, while the
former favours 80% solutions that
Nick Coghlan added the comment:
Somewhat related, I *know* you've read type.__new__. Compared to that,
enum.EnumMeta.__new__ is still pretty straightforward ;)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
Eli Bendersky added the comment:
Ethan, just a reminder to write that documentation...
It's basically a stripped down version of PEP 435 (leave all the philosophy and
history out), with a few concrete reference sections explaining the API
precisely.
--
Changes by Donald Stufft donald.stu...@gmail.com:
--
nosy: +dstufft
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
___
Python-bugs-list
Donald Stufft added the comment:
Small nitpick, weakref is imported but not used in the latest patch.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Ethan Furman added the comment:
Got the pickle issues worked out. Added super to the metaclass' __new__.
Checking for illegal names of members and raising ValueError if any are found
(I know, I know, safety checks! But such an enum is broken from the getgo so I
see no reason to allow those
Changes by Phil Connell pconn...@gmail.com:
--
nosy: +isoschiz, pconnell
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
___
Guido van Rossum added the comment:
Here's the promised explanation why I want to keep the getframe hack. I'm sure
it won't satisfy everyone, but this will have to do.
There are two parts to my argument. TL;DR: (a) by implementing this hack, we
will maximize user happiness; (b) I expect
Alex Gaynor added the comment:
From PyPy's perspective we don't really care what you name this particular
bikeshed, and it's probably not that important to us (in this particular case).
As far as I know IronPython is the only Python VM that doesn't have _getframe()
support by default (you
Zachary Ware added the comment:
I've come across something in the implementation here that I'd like some
clarification on. What is the purpose of overriding __dir__ in Enum and
EnumMeta? It doesn't change any behavior that I'm aware of, just makes things
look a little nicer when someone
Nick Coghlan added the comment:
Thanks Guido, now that I fully understand your reasoning, I can accept that
this is a valid practicality beats purity situation.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
Nick Coghlan added the comment:
Guido has promised an explanation for why he wants to keep the frame hack once
he is back at work next week. To help him target that reply appropriately for
my concrete objections to retaining it, I'd like to explain a bit more about
why I think it's
Nick Coghlan added the comment:
I also created issue 17959 to track a legitimate concern with the current
aliasing design, without impacting incorporation of the accepted PEP.
--
___
Python tracker rep...@bugs.python.org
Nick Coghlan added the comment:
Another post-incorporation proposal (issue 17961) relating to the values used
for the functional API.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
Ethan Furman added the comment:
After more thought, I think we should leave the shortened version of
_StealthProperty as is.
The reasoning being that if _StealthProperty does the __getattr__ lookup
itself, and fails, it will return an AttributeError... and then Python will use
__getattr__
Eli Bendersky added the comment:
Nick, could you open a separate issue for the frame hack discussion, like you
did for the other things? You can make this one depend on it, if you feel it's
a blocker, but let's please not intermix more discussion here.
--
Eli Bendersky added the comment:
Ethan, I pasted the minimized version to point out the problem; I fully agree
it should do the getattr lookup because otherwise it's very difficult to
understand what's going on. Let's keep exceptions for actual exceptional
situations and explicitly code the
Nick Coghlan added the comment:
Eli: done, created as #17963
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
___
Python-bugs-list
Ethan Furman added the comment:
Here's the latest patch.
Note that the functional API portion is broken, and I'll get back to that this
evening. Please only comment on the working code. ;)
I'll make that _MemborOrProperty name change then as well.
--
Added file:
Nick Coghlan added the comment:
The accepted PEP states that the frame hack should be removed: To support
pickling of these enums, the module name can be specified using the module
keyword-only argument.
Ergo, if you don't specify it, they cannot be pickled. Explicit is better than
implicit,
Guido van Rossum added the comment:
Sorry everyone, the frame hack needs to stay. This is not negotiable.
--
nosy: +gvanrossum
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Nick Coghlan added the comment:
Why we need two ways to do it? If module=__name__ is available, what's the
rationale for providing the option of leaving it out when pickling support is
required? (The only times the frame hack will work to enable pickling, the
explicit fix will also work).
Eli Bendersky added the comment:
Ethan, something is wrong with _StealthProperty. Well, two things. First, it's
way too general and can be cut to just what Enum needs. Second, this is enough
to make the tests pass:
class _StealthProperty():
Returns the value in the instance, or the
Eli Bendersky added the comment:
Also, your test must run within the regrtest framework. Currently I get:
./python -mtest.regrtest test_enum
[1/1] test_enum
test test_enum failed -- Traceback (most recent call last):
File /home/eliben/python-src/default/Lib/test/test_enum.py, line 245, in
Roundup Robot added the comment:
New changeset 1b595399e070 by Benjamin Peterson in branch 'default':
simplify #17947 test with weakrefs
http://hg.python.org/cpython/rev/1b595399e070
--
nosy: +python-dev
___
Python tracker rep...@bugs.python.org
Benjamin Peterson added the comment:
I copied the wrong bug number. should have been #17927. sorry
--
nosy: +benjamin.peterson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Eli Bendersky added the comment:
Benjamin, I guess you can just unlink the message from the issue? [and then
your clarification, and when again this message from me ;-)]
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
Changes by Benjamin Peterson benja...@python.org:
--
Removed message: http://bugs.python.org/msg188954
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Changes by Benjamin Peterson benja...@python.org:
--
Removed message: http://bugs.python.org/msg188955
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Changes by Benjamin Peterson benja...@python.org:
--
Removed message: http://bugs.python.org/msg188956
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Ethan Furman added the comment:
Eli,
The original _StealthProperty checked to see if it was being called on instance
or class, and if it was the class it invoked __getattr__ to attempt a lookup
for an enum member. Your version does not check, but, ironically, the
exception raised is
Ethan Furman added the comment:
regrtest framework now supported (had to change the module name I was passing
in from '__main__' to __name__).
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
New submission from Ethan Furman:
PEP-0435 has been approved!
Now for lots of code review.
--
assignee: docs@python
components: Documentation, Library (Lib), Tests
files: ref435.py
hgrepos: 189
messages: 188812
nosy: barry, docs@python, eli.bendersky, stoneleaf
priority: normal
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
nosy: +ezio.melotti
stage: - patch review
type: - enhancement
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Ezio Melotti added the comment:
Can you upload the patch as a diff against the CPython repo?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Ethan Furman added the comment:
Here it is (I hope ;) .
--
keywords: +patch
Added file: http://bugs.python.org/file30192/pep-435.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Changes by Eli Bendersky eli...@gmail.com:
Removed file: http://bugs.python.org/file30191/ref435.py
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Eli Bendersky added the comment:
I don't see docs in the patch, but perhaps that should be a separate patch to
keep reviewing easier.
Also, Ethan, number the patch files in some way (like pep-435.1.patch,
pep-435.N.patch) as they go through rounds of reviews.
--
assignee: docs@python
Eli Bendersky added the comment:
OK, I sent another batch of reviews through the code review system - Ethan you
should've gotten an email about it.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
Eli Bendersky added the comment:
Regarding module vs. module_name for the extra param in the functional API,
Guido rightly points out in issue 17941 that __module__ is the class attribute,
so module is a consistent choice.
--
___
Python tracker
Changes by Alex Gaynor alex.gay...@gmail.com:
--
nosy: +alex
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
___
Python-bugs-list mailing
Ethan Furman added the comment:
Incorporated comments.
--
Added file: http://bugs.python.org/file30195/pep-0435_2.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Changes by Ethan Furman et...@stoneleaf.us:
--
hgrepos: -189
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
___
Python-bugs-list mailing
Changes by Zachary Ware zachary.w...@gmail.com:
--
nosy: +zach.ware
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
___
Python-bugs-list
Ethan Furman added the comment:
More adjustments due to review.
--
Added file: http://bugs.python.org/file30202/pep-0435_3.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17947
___
Ethan Furman added the comment:
Round 4. I wonder if I should have used two digits to number the patches. ;)
--
Added file: http://bugs.python.org/file30209/pep-0435_4.patch
___
Python tracker rep...@bugs.python.org
Eli Bendersky added the comment:
By the way, if anyone is willing to take on the documentation, that could be of
great help. It shouldn't be very hard since PEP 435 is extremely detailed. The
stdlib .rst doc would be the descriptions from PEP 435 plus a reference of the
exposed classes which
Nick Coghlan added the comment:
Two requests:
1. Lose the frame hack. With the explicit module=__name__ API available, the
implicit fragile magic isn't necessary and leads to Enum instances that may or
may not support pickling depending on the implementation. Better to say if you
use the
Eli Bendersky added the comment:
On Fri, May 10, 2013 at 8:09 PM, Nick Coghlan rep...@bugs.python.orgwrote:
Nick Coghlan added the comment:
Two requests:
1. Lose the frame hack. With the explicit module=__name__ API available,
the implicit fragile magic isn't necessary and leads to Enum
Eli Bendersky added the comment:
2. Mike Bayer (SQL Alchemy author) has requested the ability to derive a
custom metaclass that turns off the Enums-with-members-are-final
subclassing restriction (relaxing the rule that members of an enum are
instances of that enum to members of an enum are
81 matches
Mail list logo