It has been '0' days since I have been made extremely angry by Django and its sometimes terrible documentation that is apparently written for either deep Django experts or total novices. I am just a person with a Django application who would like to know why the Ubuntu 24.04 mod_wsgi causes it to render empty 'form.non_field_errors' and 'field.errors' as '[]' instead of nothing. Because of Python and Django bullshit, presumably, but I need to fix it.
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:
As chased down by @ewenmcneill this is a Python 3.12 bug that is fixed in 3.12.5[1], in "gh-117482: Unexpected slot wrappers are no longer created for builtin static types in subinterpreters"[2] per the changelog[3]. Will Ubuntu backport a fix or update 24.04 to a newer 3.12.x? Who knows.
(The issue applies to multiple builtin types, not just 'list'.)
Dear everyone writing release notes for software: if you have a specific term for something, please do not decide to sometimes hyphenate it ('sub-interpreter') and sometimes not ('subinterpreter'). People searching your release notes for notes on things will not appreciate your cleverness.
(You can apparently get this during interpreter shutdown if you have __del__ methods. It's fun times if you're already debugging some other Python problem.)
It turns out that my mystery is not a Django problem, it is a 'mod_wsgi on Ubuntu 24.04' problem, where things running under mod_wsgi silently wind up with an incorrect method resolution order. How do you even do that, especially when __mro__ is not affected?
(Is mod_wsgi playing around with the insides of the Python interpreter?)
And yes it is specifically the Ubuntu 24.04 version of mod_wsgi; both 20.04 and 22.04 mod_wsgi work fine. Conveniently I have a very simple reproduction case, inconveniently Ubuntu bug reports famously do nothing.
Perhaps this machine will become an Ubuntu 22.04 machine instead of the planned 24.04 update.
Our Ubuntu 24.04/mod_wsgi mystery keeps being deeper: it's been pointed out that list doesn't normally have a __str__ method; normally it comes from 'object'. So our real problem is that the list builtin in mod_wsgi executed Python has acquired a __str__ special method (!!).
@cks Reminds me of why I got interested in Unix typo(1) at first, consistent spelling being important. And in English things like referrer vs. referer or the more typical color vs. colour are rather frequent.