-
Notifications
You must be signed in to change notification settings - Fork 185
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels