[Bug]: `accumulate.__reduce__()` builds its `chain` from a list when the running total is `None`
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
- Nửa ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start in graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/itertools/AccumulateBuiltins.java, in the ReduceNode for both the None-total and initial branches. Run the reproduction from the issue and compare source.reduce() with CPython 3.12/3.13. Done when the GraalPy output has the same shape as CPython's chain((None,), it) and pickle.dumps(a) gives identical bytes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
accumulate.__reduce__() builds the replacement chain from a list of iterators when the running total is None, where CPython calls chain((None,), it). The restored iterator yields the same values, but pickle.dumps() gives different bytes.
Operating system
macOS
CPU architecture
ARM64
GraalPy version
master 3289197e63 (Python 3.13.14), built with mx python-jvm
JDK version
No response
Context configuration
No response
Steps to reproduce
This applies to the 3.12 and 3.13 lines only: itertools pickle support is deprecated there and removed in 3.14.
import itertools
a = itertools.accumulate([1, 2, 3], lambda x, y: None)
next(a)
next(a)
chain = a.__reduce__()[1][0].__reduce__()[1][0]
source = chain.__reduce__()[2][0]
| Expression | GraalPy | CPython |
|---|---|---|
source.__reduce__() |
(<built-in function iter>, ([<iterator object at 0x...>, <iterator object at 0x...>],), 0) |
(<built-in function iter>, (((None,), <list_iterator object at 0x...>),), 0) |
Expected behavior
The CPython column above (3.12.13 and 3.13.14).
Stack trace
Additional context
Root Cause
When the running total is None, accumulate.__reduce__ fills the replacement chain by hand, with a source that iterates over a list holding iter([None]) and the underlying iterator. CPython calls chain((None,), it), whose source iterates over the argument tuple. The restored iterator yields the same values, but pickle.dumps(a) gives different bytes. The initial branch just above builds its chain by hand in the same way.
Fix Suggestion
In both branches of ReduceNode, set the chain's source to an iterator over the tuple ((value,), iterable) and leave its active iterator unset.
- Ngôn ngữ chính
- Python
- Star
- 1.7k
- Fork
- 167
- Merge trung bình
- 3 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 68
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
- Không 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 oracle/graalpython
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
oracle/graalpython#1105 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
oracle/graalpython#1102 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mmap.mmap.move() is missingCó thể đã có người làm @deronnax đã nhận 3 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
oracle/graalpython#1368 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mmap extended slicing ignores the step; negative steps raise java.lang.IndexOutOfBoundsExceptionĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
oracle/graalpython#1367 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
oracle/graalpython#1366 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của oracle/graalpython
Issue tương tự
-
Độ 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
-
bug improve content
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
opensafely/documentation#2102 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
difficulty:1 documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
MakazhanAlpamys/Soup#3533 ·
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 74/100
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 76/100
onyx-dot-app/onyx#18730 ·
Maintainer thường phản hồi trong vòng 1 ngày