cmath.log(0, base) returns (-inf+nanj) instead of raising ValueError
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Start at cmath_log_impl, where the issue says c_log(z)'s domain error is lost when c_log(base) resets errno. Read the existing tests for cmath.log and run the focused cmath tests. Done means cmath.log(0, base) raises ValueError: math domain error while existing base-related behavior remains covered.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug report
cmath.log(0) raises ValueError, but cmath.log(0, base) returns a value such as (-inf+nanj) for most bases. In cmath_log_impl, the domain error from c_log(z) is stored in errno, and the second call c_log(base) resets errno to 0 before it is checked.
import cmath, math
cmath.log(0) # ValueError: math domain error
cmath.log(0, 2) # (-inf+nanj)
cmath.log(0, -1) # (nan+infj)
math.log(0, 2) # ValueError: expected a positive input
Expected: cmath.log(0, base) raises ValueError: math domain error, the same as cmath.log(0) and math.log(0, 2). A zero or one base already raises (cmath.log(2, 0), cmath.log(2, 1)), because there the error comes from the second call or from the division.
CPython versions tested on:
3.15, CPython main branch
Operating systems tested on:
Linux
Found while building a Lean 4 model of CPython (https://broyojo.com/python-formalization/). AI tools (Claude) helped investigate the findings and prepare this report. The examples were rerun on CPython 3.15.2 and main, and the report received technical review. Record: mathint-cmath-log-base-errno
- Ngôn ngữ chính
- Python
- Star
- 78.2k
- Fork
- 36.6k
- Merge trung bình
- 19 giờ 57 phút
- Pull request đã merge (30 ngày)
- 630
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python/cpython
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
stdlib type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
extension-modules stdlib topic-XML type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
python/cpython#161807 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
stdlib type-feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
python/cpython#161788 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
extension-modules topic-IO type-bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của python/cpython
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
cpp-best-practices/project_validator#267 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Project-N-E-K-O/N.E.K.O#3725 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Sending a Telegram message chain twice duplicates mentionsCó thể đã có người làm @123XieC đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AstrBotDevs/AstrBot#11125 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend bug priority: high
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
nooriegarg/ContribIQ#73 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug p3 security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày