the repeated code could be removed by always using snprintf and PyErr_SetString, probably cleaner

a stack array has the issue that you don't know the size required, but is a minor issue as it is unlikely to change

another alternative would be to just retake the gil, but that probably implies passing in the stored threadstate.