[issue18924] Enum members are easily replaced

2013-09-06 Thread Ethan Furman
Ethan Furman added the comment: In retrospect the read-only properties would not be any more difficult to get around than the __setattr__ solution, and it would conflict with our use of _RouteClassAttributeToGetattr. To properly replace an enum member one has to change two internal data struc

[issue18924] Enum members are easily replaced

2013-09-06 Thread Roundup Robot
Roundup Robot added the comment: New changeset 1d88d04aade2 by Ethan Furman in branch 'default': Close #18924: Block naive attempts to change an Enum member. http://hg.python.org/cpython/rev/1d88d04aade2 -- nosy: +python-dev resolution: -> fixed stage: patch review -> committed/rejecte

[issue18924] Enum members are easily replaced

2013-09-05 Thread Ethan Furman
Ethan Furman added the comment: Heavy-handed would be having the metaclass turn all the enum members into read-only properties. The solution I have proposed is more like a wagging of one's finger saying, "No, no, that's not the right way!" ;) -- _

[issue18924] Enum members are easily replaced

2013-09-05 Thread Eric Snow
Eric Snow added the comment: > I would agree with Eli and Eric if it wasn't for that problem. Agreed. That was the gist of my question that led to Ethan's example. If it's easy to accidentally break an enum, particularly in a subtle way, then it may not be worth taking a consenting adults ap

[issue18924] Enum members are easily replaced

2013-09-05 Thread Antoine Pitrou
Antoine Pitrou added the comment: I think Ethan has a point that the inconsistency when overriding a member can hide subtle bugs. I would agree with Eli and Eric if it wasn't for that problem. Also, we can first forbid overriding, then change our decision later on if someone comes with a use c

[issue18924] Enum members are easily replaced

2013-09-05 Thread Eli Bendersky
Eli Bendersky added the comment: On Wed, Sep 4, 2013 at 3:05 PM, Ethan Furman wrote: > > Ethan Furman added the comment: > > Yes, as a matter of fact: > > --> Test.this > > --> Test.this = 'other' > --> Test.this > 'other' > --> Test('that') > > --> list(Test) > [] > > As you can see, the Tes

[issue18924] Enum members are easily replaced

2013-09-04 Thread Ethan Furman
Changes by Ethan Furman : -- stage: -> patch review Added file: http://bugs.python.org/file31596/issue18924.stoneleaf.patch.01 ___ Python tracker ___ ___

[issue18924] Enum members are easily replaced

2013-09-04 Thread Eric Snow
Eric Snow added the comment: I'm also -1, though I do appreciate the "indicating intent" argument. What's the risk that someone will accidentally overwrite an enum item? Also, is there other enum functionality that relies on the continued existence of the initial enum items? If not then I'm

[issue18924] Enum members are easily replaced

2013-09-04 Thread Ethan Furman
Ethan Furman added the comment: Yes, as a matter of fact: --> Test.this --> Test.this = 'other' --> Test.this 'other' --> Test('that') --> list(Test) [] As you can see, the Test Enum becomes inconsistent if this is allowed. -- ___ Python tracker

[issue18924] Enum members are easily replaced

2013-09-04 Thread Eli Bendersky
Eli Bendersky added the comment: On Wed, Sep 4, 2013 at 1:57 PM, Ethan Furman wrote: > > Ethan Furman added the comment: > > Eli Bendersky added the comment: > > > > So let's stop trying to make enums even more alien. This is a non-issue > in Python. > > Enumerations are supposed to be constant

[issue18924] Enum members are easily replaced

2013-09-04 Thread Ethan Furman
Ethan Furman added the comment: Eli Bendersky added the comment: > > So let's stop trying to make enums even more alien. This is a non-issue in > Python. Enumerations are supposed to be constant. Since this is Python there is actually very little that cannot be changed, but we can make objec

[issue18924] Enum members are easily replaced

2013-09-04 Thread Eli Bendersky
Eli Bendersky added the comment: "You do not have permission to edit user" - in a red banner, no less. Blasphemy. -- ___ Python tracker ___ __

[issue18924] Enum members are easily replaced

2013-09-04 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: On Sep 04, 2013, at 08:18 PM, Eli Bendersky wrote: >[Barry, how come your name in the tracker is linked to your website? me >wants...] Go to "Your Details" in the left sidebar and enter a "Homepage". -- ___ Python

[issue18924] Enum members are easily replaced

2013-09-04 Thread Ethan Furman
New submission from Ethan Furman: Python 3.4.0a1+ (default:33727fbb4668+, Aug 31 2013, 12:34:55) [GCC 4.7.3] on linux Type "help", "copyright", "credits" or "license" for more information. --> import enum --> class Test(enum.Enum): ... this = 'that' ... --> Test.this --> Test.this = 9 --> Te

[issue18924] Enum members are easily replaced

2013-09-04 Thread Eli Bendersky
Eli Bendersky added the comment: Time for your friendly devil's advocate... We're using and loving this language: >>> class Foo: ... bar = 2 ... >>> f = Foo() >>> f.bar 2 >>> f.bar = 42 >>> f.bar 42 >>> So let's stop trying to make enums even more alien. This is a non-issue in Python. [B

[issue18924] Enum members are easily replaced

2013-09-04 Thread Ethan Furman
Ethan Furman added the comment: I'm not suggesting we try to make it impossible, just tougher (akin to what we did with the name and value attributes on an Enum member -- at Guido's behest, no less ;). -- ___ Python tracker

[issue18924] Enum members are easily replaced

2013-09-04 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: On Sep 04, 2013, at 07:47 PM, Ethan Furman wrote: >I'm pretty sure we don't want that. Agreed, although a "we're all consenting adults" argument could be made. -- ___ Python tracker