It appears that Canonical has done something unusual to Python sub-interpreters in the Ubuntu 24.04 version of Python, such that if you create one in your code (as mod_wsgi normally does), list.__str__ gets set there where it normally doesn't exist. Interested parties can try out this test program:
https://www.cs.toronto.edu/~cks/vendors/ubuntu2404-python/subinterp-list-bug.c
I guess now I have to try to summon the energy to file an Ubuntu bug. Please feel free to beat me to it.