Skip to content

Random "TypeError: object not callable" for a bound method when called from C #14377

Discussion options

You must be logged in to vote

Sometimes there is no "TypeError: object not callable" when the callback gets called, but a plain crash

This seemingly random behavior often is a result of a piece of memory allocated for the callback getting garbage collected. The first error is then quite typically because the memory which was originally allocated for the callback (i.e. some function object) itself was freed, and then allocated again for another type of object which happens to not be callable. To fix this you 'd have to make sure that the pointer to your callback memory is reachable by the grbage collector such that it sees it's in use, e.g. by storing it in a list which itself is registered as root pointer. Alternati…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@MHe999
Comment options

Answer selected by MHe999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants