python / python/cpython

Incompatibility between _decimal and _pydecimal: Context.__hash__

Open
#94,107 7 comments 1 reaction 1 assignee View on GitHub

@rhettinger is already working on this.

Since Jun 22, 2022.

extension-modules type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Bug report

_decimal.Context.__hash__() returns an int value, while _pydecimal.Context.__hash__() is explicitly disabled:

Python 3.10.5 (main, Jun  7 2022, 12:59:15) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from _decimal import Context
>>> Context().__hash__()
8743628939711
>>> from _pydecimal import Context
>>> Context().__hash__()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable

I assume that _decimal just didn't bother to override __hash__ and inherits its implementation from object, but I think the implementations should match.

Your environment

Tested:

  • Python 3.10.5 (main, Jun 7 2022, 12:59:15) [GCC 10.2.1 20210110] on linux
  • Python 3.9.2 (default, Feb 28 2021, 17:03:44)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.