[issue14617] confusing docs with regard to __hash__

2012-09-12 Thread Raymond Hettinger

Raymond Hettinger added the comment:

This can wait until after the release.  We will have periodic point releases 
where further doc updates can go in.

--
nosy: +rhettinger

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



[issue14617] confusing docs with regard to __hash__

2012-09-11 Thread Ethan Furman

Ethan Furman added the comment:

RC2 has just been released.  Any chance of this getting in to the final 
release?  Nobobdy has pointed out any problems with the last update...

--

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



[issue14617] confusing docs with regard to __hash__

2012-09-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 957e1eef3296 by R David Murray in branch '3.2':
#14617: clarify discussion of interrelationship of __eq__ and __hash__.
http://hg.python.org/cpython/rev/957e1eef3296

New changeset c8d60d0c736b by R David Murray in branch 'default':
Merge #14617: clarify discussion of interrelationship of __eq__ and __hash__.
http://hg.python.org/cpython/rev/c8d60d0c736b

--
nosy: +python-dev

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



[issue14617] confusing docs with regard to __hash__

2012-09-11 Thread R. David Murray

R. David Murray added the comment:

I rewrote the section a bit differently than you did in your patch...if you 
think my changes are not an improvement please let me know.

--
nosy: +r.david.murray
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue14617] confusing docs with regard to __hash__

2012-09-11 Thread Ethan Furman

Ethan Furman added the comment:

R. David Murray wrote:
 I rewrote the section a bit differently than you did in your patch...if you 
 think my changes are not an improvement please let me know.

This line is incorrect:

A class which defines its own :meth:`__hash__` that explicitly raises a 
:exc:`TypeError` would be incorrectly identified as hashable by an 
``isinstance(obj, collections.Hashable)`` call.

It should be would not be correctly identified as hashable.

Otherwise, looks great.

--

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



[issue14617] confusing docs with regard to __hash__

2012-09-11 Thread Ethan Furman

Ethan Furman added the comment:

Ethan Furman wrote:
 Ethan Furman added the comment:
 
 R. David Murray wrote:
 I rewrote the section a bit differently than you did in your patch...if you 
 think my changes are not an improvement please let me know.
 
 This line is incorrect:
 
 A class which defines its own :meth:`__hash__` that explicitly raises a 
 :exc:`TypeError` would be incorrectly identified as hashable by an 
 ``isinstance(obj, collections.Hashable)`` call.
 
 It should be would not be correctly identified as hashable.
 
 Otherwise, looks great.

Argh.  Nevermind!  It all looks good.  :)

--

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



[issue14617] confusing docs with regard to __hash__

2012-08-20 Thread Ethan Furman

Ethan Furman added the comment:

Any problems with the current doc patch?  If not, can it be applied before RC1?

--

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



[issue14617] confusing docs with regard to __hash__

2012-08-20 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +ncoghlan

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



[issue14617] confusing docs with regard to __hash__

2012-05-25 Thread Ethan Furman

Ethan Furman et...@stoneleaf.us added the comment:

Newest changes uploaded.

--
Added file: http://bugs.python.org/file25707/__hash__3.diff

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



[issue14617] confusing docs with regard to __hash__

2012-05-22 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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



[issue14617] confusing docs with regard to __hash__

2012-05-21 Thread Ethan Furman

Ethan Furman et...@stoneleaf.us added the comment:

Are the changes good?  Can they be commited?

--

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



[issue14617] confusing docs with regard to __hash__

2012-04-20 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue14617] confusing docs with regard to __hash__

2012-04-18 Thread Ethan Furman

New submission from Ethan Furman et...@stoneleaf.us:

From http://docs.python.org/py3k/reference/datamodel.html#object.__hash__
---
Classes which inherit a __hash__() method from a parent class but change the 
meaning of __eq__() such that the hash value returned is no longer appropriate 
(e.g. by switching to a value-based concept of equality instead of the default 
identity based equality) can explicitly flag themselves as being unhashable by 
setting __hash__ = None in the class definition. Doing so means that not only 
will instances of the class raise an appropriate TypeError when a program 
attempts to retrieve their hash value, but they will also be correctly 
identified as unhashable when checking isinstance(obj, collections.Hashable) 
(unlike classes which define their own __hash__() to explicitly raise 
TypeError).

If a class that overrides __eq__() needs to retain the implementation of 
__hash__() from a parent class, the interpreter must be told this explicitly by 
setting __hash__ = ParentClass.__hash__. Otherwise the inheritance of 
__hash__() will be blocked, just as if __hash__ had been explicitly set to None.
---

The first paragraph says the user has to change __hash__ if it's different 
because of changes to __eq__, the second paragraph says __hash__ is 
automatically removed if __eq__ is changed;  the second paragraph reflects 
reality.

Proposed change:
---
Classes which change the meaning of __eq__() (thus losing automatic delegation 
to the parent class' __hash__) can explicitly flag themselves as being 
unhashable by setting __hash__ = None in the class definition (which is 
otherwise done implicity). Having __hash__ set to None, either explicitly or 
implicitly, means that not only will instances of the class raise an 
appropriate TypeError when a program attempts to retrieve their hash value, but 
they will also be correctly identified as unhashable when checking 
isinstance(obj, collections.Hashable) (unlike classes which define their own 
__hash__() to explicitly raise TypeError).

If a class that overrides __eq__() needs to retain the implementation of 
__hash__() from a parent class, the interpreter must be told this explicitly by 
setting __hash__ = ParentClass.__hash__.
---

Patch attached.

--
assignee: docs@python
components: Documentation, Interpreter Core
files: __hash__.diff
keywords: patch
messages: 158644
nosy: docs@python, stoneleaf
priority: normal
severity: normal
status: open
title: confusing docs with regard to __hash__
type: behavior
versions: Python 3.1, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file25261/__hash__.diff

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



[issue14617] confusing docs with regard to __hash__

2012-04-18 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
versions: +Python 2.7 -Python 3.1

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



[issue14617] confusing docs with regard to __hash__

2012-04-18 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Some of the sentence phrasing still sounds a bit awkward to me (“[...], means 
that not only will instances” for example, and I would also remove the parens 
at the end), but globally I think this is an improvement.

--
nosy: +eric.araujo

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



[issue14617] confusing docs with regard to __hash__

2012-04-18 Thread Ethan Furman

Ethan Furman et...@stoneleaf.us added the comment:

Éric Araujo wrote:
 Changes by Éric Araujo mer...@netwok.org:
 
 
 --
 versions: +Python 2.7 -Python 3.1

The docs for 2.7 are correct, as __hash__ is not automatically 
suppressed in that version.
--
~Ethan~

--

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



[issue14617] confusing docs with regard to __hash__

2012-04-18 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
versions:  -Python 2.7

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



[issue14617] confusing docs with regard to __hash__

2012-04-18 Thread Ethan Furman

Ethan Furman et...@stoneleaf.us added the comment:

More re-writing...

--
Added file: http://bugs.python.org/file25264/__hash__2.diff

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