Skip to content

fix: Prevent PendingObject from pickling ObjDomain reference#61

Merged
SilverRainZ merged 2 commits into
masterfrom
fix/unpicklable-pending-object
May 12, 2026
Merged

fix: Prevent PendingObject from pickling ObjDomain reference#61
SilverRainZ merged 2 commits into
masterfrom
fix/unpicklable-pending-object

Conversation

@SilverRainZ
Copy link
Copy Markdown
Member

@SilverRainZ SilverRainZ commented May 12, 2026

Summary

  • Change PendingObject.domain from ObjDomain to domain: str
  • Use env.get_domain() in resolve() to look up the domain at runtime
  • This prevents pickle failures during doctree serialization

Root Cause

PendingObject (an UnresolvedContext) stored a direct reference to
ObjDomain, which contains unpicklable local functions (XRefRole closures
in _role_cache). When Sphinx serializes the doctree via
pickle.dump(doctree), it fails because these closures cannot be pickled.

Dependencies

Requires sphinx-notes/render#14 (adds env
parameter to UnresolvedContext.resolve()).

SilverRainZ and others added 2 commits May 13, 2026 00:55
Storing ObjDomain directly in the PendingObject dataclass causes pickle
failures during doctree serialization because the domain contains
unpicklable local functions (XRefRole closures in _role_cache).

Store the domain name (str) instead of the domain instance, and look up
the domain at resolve time via env.get_domain().

This depends on sphinx-notes/render#14 which adds the env parameter to
UnresolvedContext.resolve().

Co-Authored-By: DeepSeek V4 Pro <service@deepseek.com>
@SilverRainZ SilverRainZ force-pushed the fix/unpicklable-pending-object branch from 76554f1 to 94f8191 Compare May 12, 2026 16:56
@SilverRainZ SilverRainZ merged commit 4a87d43 into master May 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant