[issue19249] Enumeration.__eq__

2013-11-13 Thread Ethan Furman

Ethan Furman added the comment:

changeset ca909a3728d3

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19249
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19249] Enumeration.__eq__

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Since the default eq implementation handles ducktyping correctly, dropping the 
Enum specific __eq__ implementation should be fine.

Just make sure this still works:

 class AlwaysEqual:
... def __eq__(self, other):
... return True
... 
 from enum import Enum
 class MyEnum(Enum):
... a = 1
... 
 MyEnum.a == AlwaysEqual()
True
 AlwaysEqual() == MyEnum.a
True

--
nosy: +ncoghlan
stage:  - test needed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19249
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19249] Enumeration.__eq__

2013-11-10 Thread Ethan Furman

Ethan Furman added the comment:

Done and done.

--
stage: test needed - patch review
Added file: http://bugs.python.org/file32572/issue19249.stoneleaf.02.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19249
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19249] Enumeration.__eq__

2013-11-08 Thread Ethan Furman

Ethan Furman added the comment:

Given that __eq__ isn't adding anything, I think removing it is a fine option.

--
keywords: +patch
Added file: http://bugs.python.org/file32548/issue19249.stoneleaf.01.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19249
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19249] Enumeration.__eq__

2013-10-19 Thread CliffM

CliffM added the comment:

It is appropriate to modify the pickle-module to trap (a potential) the 
singletonicity-breaking event and raise a warning ? (I'm guessing an exception 
would be far too rude)

I like the idea of using identity-equality, but without the above trap one 
might get really weird bugs without a deep reading of the docs and/or code.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19249
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19249] Enumeration.__eq__

2013-10-19 Thread Ethan Furman

Ethan Furman added the comment:

Given the rarity of singletons, I don't think changing pickle in that way is 
appropriate.  Besides, pickle protocol 2 and above don't have the problem.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19249
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19249] Enumeration.__eq__

2013-10-13 Thread CliffM

New submission from CliffM:

Given that enumeration members are Singletons, can we not rely on the default
__eq__() method ?  (FWIW the existing tests all pass if you delete it)

This might be confusing for a reader later, so needs documenting.  Although I 
think it should be documented (in enum.py) either way.

Maybe also add a singletoness test ?

def test_singleton(self):
class A(Enum):
X=1
Y=2

self.assertTrue(id(A.X)==id(A.X))


Of course there is good chance that there is a test-case I have not thought of 
that will defeat this.  I am thinking about :

a) weak-ref handling of Enums 

b) unpickling, say by a user of the ZODB

Which might break the singletonicity. ??  Any offers ??

--
components: Tests
messages: 199774
nosy: CliffM
priority: normal
severity: normal
status: open
title: Enumeration.__eq__
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19249
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19249] Enumeration.__eq__

2013-10-13 Thread Ethan Furman

Ethan Furman added the comment:

Here's the current __eq__ method:

def __eq__(self, other):
if type(other) is self.__class__:
return self is other
return NotImplemented

It is, in fact, using identity and not value equality.

I'm thinking we should either remove and go with the default __eq__, or change 
it to value equality.  One possible reason to use value equality is that pickle 
protocols below 2 will actually create duplicate Enum members, breaking 
identity tests; if someone is stuck using pickle that way, they could still use 
Enum with `==` and not `is`.

Identity tests are already incorporated in many of the existing tests.

Gentlemen, what do you think?

--
assignee:  - ethan.furman
nosy: +barry, eli.bendersky, ethan.furman
type:  - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19249
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com