Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

register_pickle_by_value appears to not deliver monkeypatches to receiver

Đang mở
#586 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ví dụ gồm hai môi trường xoay quanh register_pickle_by_value(), cloudpickle.dumps() và pickle.loads(), đồng thời so sánh hành vi của tdb.my_function đã được patch ở cả hai phía. Theo dõi cách lambda và tham chiếu đến module tdb được biểu diễn và phân giải, sau đó ghi lại liệu kết quả quan sát được có đúng như dự kiến hay xác định hành vi lỗi nhỏ nhất cần kiểm thử.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Should I expect register_pickle_by_value() to deliver monkeypatches? I don't know if what I'm observing is a bug or only missing functionality.

I have two python environments, A and B. Each has cloudpickle 3.1.2 installed and also a package that I'm developing at work. Let's call it "tdb". I run a script in environment A that looks like this:

import sys

import cloudpickle
import tdb

# monkeypatch an attribute of tdb.
tdb.my_function = lambda *args, **kwargs: ["fake", "values"]

def func():
    return tdb.my_function()

assert func() == ["fake", "values"]

cloudpickle.register_pickle_by_value(tdb)
pickle_data = cloudpickle.dumps(func, protocol=4)
sys.stdout.buffer.write(pickle_data)

I'm piping the output to a script that runs in environment B

import pickle
import sys

pickle_data = sys.stdin.buffer.read()
print(pickle_data)

func = pickle.loads(pickle_data)
print(func())

But I see the original tdb.my_function being called in environment B, not my monkeypatch.

The odd thing is that I can see lambda when I print the pickle stream in environment B. It's there in some sense, but isn't being understood on the receiver side.

Ngôn ngữ chính
Python
Star
1.9k
Fork
197
Merge trung bình
1 ngày 10 giờ
Pull request đã merge (30 ngày)
1

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

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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.

Issue khác của cloudpipe/cloudpickle

Tất cả issue của cloudpipe/cloudpickle

Issue tương tự

Thêm issue về Python

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.