This broke between 3.0 and 3.1, upgrading to Python 3.10 seems the likely cause as this code didn't change.