I've encountered this issue through Ubuntu and made a patch: https://git.launchpad.net/ubuntu/+source/m2crypto/tree/debian/patches/ftbfs-swig-4.3-changed-exception.patch
The patch loses compat with SWIG < 4.3 however so maybe not fit for inclusion upstream, I haven't started discussing that upstream yet. There is another FTBFS due to SWIG reading sys/select.h with openssl 3.4 and for that I don't have a good solution but only a work-around to be applied to openssl: https://git.launchpad.net/ubuntu/+source/openssl/tree/debian/patches/Revert-When-defining-ossl_ssize_t-ssize_t-remember-t.patch -- Adrien