Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

register_pickle_by_value appears to not deliver monkeypatches to receiver

Open
#586 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
tooling

Research direction

Start by reproducing the two-environment example around register_pickle_by_value(), cloudpickle.dumps(), and pickle.loads(), comparing the behavior of the patched tdb.my_function on both sides. Trace how the lambda and the tdb module reference are represented and resolved, then document whether the observed result is expected or identify the smallest failing behavior to test.

Written by the indexing model from the issue text.

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.

Dominant language
Python
Stars
1.9k
Forks
197
Avg merge
1d 10h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudpipe/cloudpickle

All issues in cloudpipe/cloudpickle

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.