Fix callback handling and flag initialization#629
Open
ThatOneFBIAgent wants to merge 1 commit intospatialaudio:masterfrom
Open
Fix callback handling and flag initialization#629ThatOneFBIAgent wants to merge 1 commit intospatialaudio:masterfrom
ThatOneFBIAgent wants to merge 1 commit intospatialaudio:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Python 3.14, cffi changed how it passes arguments to native callbacks
and how it validates
__init__return values. This caused two distinct errors:TypeError: __init__() should return None, not 'NoneType'cffi now intercepts and validates the return of
__init__at a lowerlevel, causing it to spuriously reject the standard
Nonereturn.TypeError: unsupported operand type(s) for &: '_CDataBase' and 'int'The
statusargument now arrives as a raw_CDataBaseobject insteadof a plain Python int, breaking bitwise operations in
_hasflag.Both errors surface in
_wrap_callbackand occur unpredictably duringstream callbacks, including during silence and active playback.
Fix
Bypass
CallbackFlags.__init__entirely in_wrap_callbackusing__new__, then set_flagsdirectly viaint()cast. This avoidsthe cffi
__init__interception and the_CDataBasebitwise issuein one shot.
Changes
In
_wrap_callback, replace:args = args[:-1] + (CallbackFlags(args[-1]),)
With:
cf = CallbackFlags.new(CallbackFlags)
cf._flags = int(status)
Tested on