square brackets bug

After poking around in Django core, I believe this issue is caused by this Python 3.12 bug relating to subinterpreters: Weird `int.__str__` behaviour inside sub-interpreters · Issue #117482 · python/cpython · GitHub I was able to reproduce the problem using a modified version of the test case.

import _xxsubinterpreters as interpreters

script = """
import django
from django.conf import settings
from django.forms.utils import ErrorList

settings.configure()
django.setup()

empty = ErrorList([])

print(str(empty))
"""

exec(script)
# Output: ""

interp_id = interpreters.create(isolated=False)
interpreters.run_string(interp_id, script)
# Output: []
1 Like