Unpacking an anomaly
summary
A production bug starts throwing TypeError: struct argument 1 must be a string not Unicode after adding from __future__ import unicode_literals; the struct module uses a struct cache keyed by the format string so a Unicode format causes the first call to fail, but previous cached string entries mask it. One Gunicorn worker’s cache expires (100-entry limit) and that worker begins failing until another request refreshes the cache; fix is to use a byte string or upgrade to the struct version that accepts Unicode.
AI-written summary · about
