[New-bugs-announce] [issue4701] range objects becomes hashable after attribute access

Hagen Fürstenau report at bugs.python.org
Fri Dec 19 16:21:11 CET 2008


New submission from Hagen Fürstenau <hfuerstenau at gmx.net>:

As reported by Dmitry Vasiliev on python-dev, a range object suddenly
becomes hash()able after an attribute access, e.g. by dir().

If I understand correctly, then the reason is that PyRange_Type doesn't
set tp_hash and PyType_Ready is not normally called on the type, but
only e.g. in PyObject_GenericGetAttr.

I don't see any use for range objects being hashable, as they don't even
have meaningful equality defined on them. So I'd recommend making them
unhashable. The attached patch does this and adds a test.

----------
components: Interpreter Core
messages: 78059
nosy: hagen
severity: normal
status: open
title: range objects becomes hashable after attribute access
type: behavior
versions: Python 3.0, Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4701>
_______________________________________


More information about the New-bugs-announce mailing list