Tested and it fixes python3.12 compatibility. Please merge.
Not mine but I think this one should be merged.