sys.setrecursionlimit no longer affecting pickle.dump
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 77.2k
- Fork
- 35.9k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
Bug report
Bug description:
This is a follow up of https://github.com/python/cpython/issues/112282 (updating doc).
It's also a different case of https://github.com/python/cpython/issues/128544 (import chains impacted).
In particular, on top of the doc no longer being correct for sys.setrecursionlimit, the regression needs to be fixed.
Note: this works in python 3.11 or below.
import pickle
import sys
nested_object = current = {}
for i in range(10000):
current['nested'] = {}
current = current['nested']
sys.setrecursionlimit(3750000)
x = pickle.dumps(nested_object)
Result of the run:
▶▶ python3.11 test-issue.py
# runs ok
▶▶ python3.12 test-issue.py
Traceback (most recent call last):
File "~/test-issue.py", line 10, in <module>
x = pickle.dumps(nested_object)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded while pickling an object
Impact: all programs trying to pickle data that is too nested cannot be ported to python 3.12 or 3.13 so far
CPython versions tested on:
3.12, 3.13
Operating systems tested on:
Linux, macOS, Windows
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.
Hướng nghiên cứu
Chạy trình tái hiện dictionary lồng nhau được cung cấp trên Python 3.11 và 3.12, sau đó theo dõi cách pickle.dumps xử lý đệ quy sau khi sys.setrecursionlimit được tăng lên. Bản sửa lỗi hoàn tất khi ví dụ chạy thành công trên các phiên bản bị ảnh hưởng mà không có RecursionError, đồng thời vẫn giữ nguyên hành vi đã được ghi rõ của giới hạn đệ quy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- backend
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100