Warning
Most of the documentation was written prior to version 0.5 and needs to be updated. This work has now started for version 0.7 and we aim to have it completed before version 0.8 is available.
Comparing Exception messages between Python versions¶
In this file, we highlight differences between the
messages provided by Python for all Exceptions excluding SyntaxError
cases; these are covered elsewhere.
Note that the content below is extracted automaticaly by a simple program we wrote for this purpose. If the information is the same for Python 3.6 and 3.7, but changes for Python 3.8, and stays the same afterwards, we only show the differences between 3.7 and 3.8.
Too many positional argument
3.9: f() takes 1 positional argument but 2 were given 3.10: test_Too_many_positional_argument.<locals>.A.f() takes 1 positional argument but 2 were given
Cannot unpack non iterable object
3.6: 'float' object is not iterable 3.7: cannot unpack non-iterable float object
Missing global
3.10: local variable 'spam_missing_global' referenced before assignment 3.11: cannot access local variable 'spam_missing_global' where it is not associated with a value
Too few positional argument
3.9: fn() missing 2 required positional arguments: 'b' and 'c' 3.10: test_Too_few_positional_argument.<locals>.fn() missing 2 required positional arguments: 'b' and 'c'
Typo in local
3.10: local variable 'alpha3' referenced before assignment 3.11: cannot access local variable 'alpha3' where it is not associated with a value
method got multiple argument
3.9: some_method() got multiple values for argument 'a' 3.10: test_method_got_multiple_argument.<locals>.T.some_method() got multiple values for argument 'a'
getattr attribute name must be string
3.10: getattr(): attribute name must be string 3.11: attribute name must be string, not 'int'
Using name of builtin
3.10: local variable 'max' referenced before assignment 3.11: cannot access local variable 'max' where it is not associated with a value
Circular import
3.7: module 'my_turtle1' has no attribute 'something' 3.8: partially initialized module 'my_turtle1' has no attribute 'something' (most likely due to a circular import)
Simple import error
3.6: cannot import name 'Pi' 3.7: cannot import name 'Pi' from 'math' (unknown location)
Circular import b
3.7: module 'circular_c' has no attribute 'something' 3.8: partially initialized module 'circular_c' has no attribute 'something' (most likely due to a circular import)
Missing nonlocal
3.10: local variable 'spam_missing_nonlocal' referenced before assignment 3.11: cannot access local variable 'spam_missing_nonlocal' where it is not associated with a value
Cant mod complex numbers
3.9: can't mod complex numbers. 3.10: unsupported operand type(s) for %: 'complex' and 'int'
function got multiple argument
3.9: fn2() got multiple values for argument 'a' 3.10: test_function_got_multiple_argument.<locals>.fn2() got multiple values for argument 'a'
Free variable referenced
3.10: free variable 'var' referenced before assignment in enclosing scope 3.11: cannot access free variable 'var' where it is not associated with a value in enclosing scope
Modulo operator
3.10: integer division or modulo by zero 3.11: integer modulo by zero
divmod
3.9: can't take floor or mod of complex number. 3.10: unsupported operand type(s) for divmod(): 'int' and 'complex'
Missing both
3.10: local variable 'spam_missing_both' referenced before assignment 3.11: cannot access local variable 'spam_missing_both' where it is not associated with a value