[New-bugs-announce] [issue32929] Change dataclasses hashing to use unsafe_hash boolean (default to False)

Eric V. Smith report at bugs.python.org
Fri Feb 23 20:44:53 EST 2018


New submission from Eric V. Smith <eric at trueblade.com>:

See https://mail.python.org/pipermail/python-dev/2018-February/152150.html for a discussion.

This will remove the @dataclass hash= tri-state parameter, and replace it with an unsafe_hash= boolean-only parameter.

>From that thread:

"""
I propose that with @dataclass(unsafe_hash=False) (the default), a __hash__
method is added when the following conditions are true:

- frozen=True (not the default)
- compare=True (the default)
- no __hash__ method is defined in the class

If we instead use @dataclass(unsafe_hash=True), a __hash__ will be added
regardless of the other flags, but if a __hash__ method is present, an
exception is raised.

Other values (e.g. unsafe_hash=None) are illegal for this flag.
"""

----------
assignee: eric.smith
components: Library (Lib)
messages: 312686
nosy: eric.smith, ned.deily
priority: release blocker
severity: normal
status: open
title: Change dataclasses hashing to use unsafe_hash boolean (default to False)
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32929>
_______________________________________


More information about the New-bugs-announce mailing list