fix a NameError inside an exception