python / python/cpython

Incompatibility between _decimal and _pydecimal: Context.__hash__

Đang mở
#94,107 7 bình luận 1 reaction 1 người được giao Xem trên GitHub

@rhettinger đang làm issue này rồi.

Từ ngày 22/6/2022.

extension-modules type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
36k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.