_pickle.UnpicklingError: Memo value not found at index 1
Đang mở
Chưa có ai nhận issue này.
3.12
3.13
3.14
docs
stdlib
type-bug
- 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:
When pickling a container object. The pickler class will store child-objects to its self.memo even if the container could not be fully pickled (and not written to the output).
This can cause references to memo objects that are not in the output stream.
import sys
import pickle
import io
buf = io.BytesIO()
pickler = pickle.Pickler(buf)
i_will_be_memorized = 'qqqqqqqqqqqq'
i_cant_be_pickled = sys
try:
pickler.dump([i_will_be_memorized, i_cant_be_pickled])
except TypeError:
# i_will_be_memorized is now in pickler memory despite the exception
pass
# this dump will use the memo
pickler.dump(i_will_be_memorized)
data = buf.getbuffer().tobytes()
# so this will fail with:
# _pickle.UnpicklingError: Memo value not found at index 1
pickle.loads(data)
CPython versions tested on:
3.12
Operating systems tested on:
Windows
Linked PRs
- gh-125762
- gh-130231
- gh-130232
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
Tái hiện lỗi bằng đoạn mã Python pickle và io.BytesIO trong issue, sau đó kiểm tra cách pickle.Pickler xử lý memo khi một lần dump container thất bại. Được coi là hoàn tất khi một lần dump sau đó không tham chiếu đến các mục memo không có trong luồng đầu ra và có kiểm thử hồi quy cho chuỗi thao tác đã nêu.
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
- Khá rõ ràng
- Mức phù hợp với người mới
- 25/100