Message 111952 - Python tracker
The error happens when Null is passed to strlen in (unicodeobject.c, line 860) Passing NULL to a string format function is probably in the category of don't do that. Stefans solution of checking for NULL before calling PyErr_Format looks to me to be correct. As he notes, the same technique is used in another place. It might be good to add a note somewhere not to pass NULL to C string format functions.