cad/py-gmsh: fix build with python 3.12
PR: 296597 (cherry picked from commit c6205e98712621eac18549ca0a24c90a73c78ecb)