The Python build system has support for -fsanitize=address through its --with-address-sanitizer flag. Pleas convert this into a useflag. Additionally, I was not able to build Python with EXTRA_ECONF="--with-address-sanitizer" for testing this. It fails during the configure step with ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD. several times, and the python ./configure won't generate a valid config.
Erm, so why are you asking us to add support for a configure option that doesn't even work? Furthermore, I believe that sanitizer magic really belongs in CFLAGS/CXXFLAGS and not USE flags. Do you have any arguments contrary to that?
I should have explained it better :) The --with-address-sanitizer option works if I build it from the source directly (without emerge). It doesn't work if I want to build it with emerge and EXTRA_ECONF, it then fails because of the reason mentioned above. I could not discover the difference between those builds yet, and why it complains in the ebuild environment. I tried building Python directly with CFLAGS and LDFLAGS for asan, but that aborts the build even earlier, so in the research process, I encountered the built-in activation mechanism. But I couldn't get it to work yet.
I don't think thre's a need to do this. It's generic to anything with ASAN because of how sandbox works, not specific to Python, just Python happens to have a configure arg for it. We have https://wiki.gentoo.org/wiki/AddressSanitizer#Per-package documented. For cases where the build system does need to do something special, see e.g. https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-libs/elfutils/elfutils-0.191.ebuild#n98 or https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-libs/botan/botan-3.3.0.ebuild#n189.