@@ -230,13 +230,26 @@ def ee(expr, g=globals(), l=locals()):
230230 cb .append (expr + ' :' + repr ((e .__class__, AttributeError (str (e )[str (e ).rfind (" '" ) + 2 :-1 ]))))
231231 elif sys.version_info >= (3 , 3 ) and e .__class__ is ImportError and str (e ).find (' No module named \' ') >= 0 :
232232 cb .append (expr + ' :' + repr ((e .__class__, ImportError (str (e ).replace (" '" , ' ' )))))
233+ elif sys.version_info >= (3 , 6 ) and e .__class__ is ModuleNotFoundError:
234+ # Python 3.6 gives ModuleNotFoundError, change it to an ImportError
235+ cb .append (expr + ' :' + repr ((ImportError, ImportError (str (e ).replace (" '" , ' ' )))))
233236 elif sys.version_info >= (3 , 3 ) and e .__class__ is TypeError:
234237 m = py33_type_error_pattern.search (str (e ))
235238 if m :
236239 msg = ' __call__() takes exactly {0} positional argument ({1} given)' .format (m .group (1 ), m .group (2 ))
237240 cb .append (expr + ' :' + repr ((e .__class__, TypeError (msg))))
238241 else :
239- cb .append (expr + ' :' + repr ((e .__class__, e )))
242+ msg = repr ((e .__class__, e ))
243+ # Messages changed with Python 3.6 , change new to old.
244+ newmsg1 = " " " 'argument must be str, bytes or bytearray, not None'" " "
245+ oldmsg1 = ' ' ' "Can' t convert ' NoneType' object to str implicitly" '''
246+ if msg.find (newmsg1) > -1 :
247+ msg = msg.replace (newmsg1, oldmsg1)
248+ newmsg2 = " " " 'argument must be str, bytes or bytearray, not int'" " "
249+ oldmsg2 = ' ' ' "Can' t convert ' int' object to str implicitly" '''
250+ if msg.find (newmsg2) > -1 :
251+ msg = msg.replace (newmsg2, oldmsg2)
252+ cb .append (expr + ' :' + msg)
240253 elif sys.version_info >= (3 , 5 ) and e .__class__ is ValueError and str (e ) == ' embedded null byte' :
241254 cb .append (expr + ' :' + repr ((TypeError, TypeError (' expected bytes with no null' ))))
242255 else :
0 commit comments