Skip to content

remove unused optr code - #10062

Merged
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:remove-optr
Aug 9, 2026
Merged

remove unused optr code#10062
ThomasWaldmann merged 1 commit into
borgbackup:masterfrom
ThomasWaldmann:remove-optr

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

Fixes #5762.

Item.to_optr/Item.from_optr and the whole _item.c (41 lines containing nothing but _object_to_optr/_optr_to_object) had exactly one caller: their own test. The mechanism — packing a raw PyObject pointer into bytes to pass an object through byte-oriented messaging without serializing it — was meant for a zeromq-based threading design that never came to borg2, and it is unsafe by nature (its own docstring warned that the object must not be deallocated between the two calls).

#5762 suggested porting it to PyCapsule; since nothing uses it, removing it seems better than modernizing it. If a message-passing design ever returns, PyCapsule would be the right tool to build fresh for it. Net: −73 lines, one C file gone.

Full test suite passes (2244 passed — exactly the removed optr test fewer than before); the item.pyi stub was updated accordingly.

🤖 Generated with Claude Code

Item.to_optr/from_optr and the whole _item.c (which contained nothing
but _object_to_optr/_optr_to_object) were only used by their own test.

The mechanism - packing a raw PyObject pointer into a bytes object to
pass an object through byte-oriented messaging without serializing it -
was meant for a zeromq-based pipeline that never came to be. Nothing in
borg calls it, and it is unsafe by nature (the docstring itself warned
that the object must not be deallocated between to_optr and from_optr).

Rather than porting it to PyCapsule (as borgbackup#5762 suggested), remove it:
if a message-passing design ever returns, PyCapsule would be the right
tool to build fresh for it.
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.76%. Comparing base (8f2de9e) to head (e481b32).
⚠️ Report is 44 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10062      +/-   ##
==========================================
+ Coverage   86.64%   86.76%   +0.11%     
==========================================
  Files          98       98              
  Lines       17037    17085      +48     
  Branches     2581     2586       +5     
==========================================
+ Hits        14762    14823      +61     
+ Misses       1583     1570      -13     
  Partials      692      692              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@ThomasWaldmann
ThomasWaldmann merged commit a7a8759 into borgbackup:master Aug 9, 2026
20 checks passed
@ThomasWaldmann
ThomasWaldmann deleted the remove-optr branch August 9, 2026 13:39
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.

port optr to pycapsule + cleanup and/or provide handles

1 participant