Skip to content

Conversation

@jwaldrop107
Copy link
Member

@jwaldrop107 jwaldrop107 commented Jun 9, 2025

Is this pull request associated with an issue(s)?
No

Description
When unwrapping an object wrapped by a PythonWrapper to a reference, the recast python object is copied into an any buffer. This buffer persists on the PythonWrapper and is checked on successive calls to unwrap to avoid repetitious effort. If the previous type being cast to isn't lossless when copied (e.g. casting an int to bool), the value stored in the buffer isn't sufficient and the underlying object needs to be reinterpreted again. This patch checks that the stored type is consistent with the requested return type, and triggers the recasting if not.

@jwaldrop107 jwaldrop107 requested a review from ryanmrichard June 9, 2025 20:16
@jwaldrop107 jwaldrop107 self-assigned this Jun 9, 2025
Copy link
Member

@ryanmrichard ryanmrichard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find! That's a heck of a subtle bug.

@jwaldrop107 jwaldrop107 merged commit c6dc654 into master Jun 9, 2025
5 checks passed
@jwaldrop107 jwaldrop107 deleted the PythonWrapper_unwrap_patch branch June 9, 2025 20:32
@jwaldrop107
Copy link
Member Author

🚀 [bumpr] Bumped!
New version:v1.0.45
Changes:v1.0.44...v1.0.45

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.

3 participants