[issue40670] supplying an empty string to timeit causes an IndentationError

Edison Abahurire report at bugs.python.org
Wed May 20 12:37:05 EDT 2020


Edison Abahurire <abahedison1 at outlook.com> added the comment:

Yes, This is unexpected

In the first case:
Supplying an empty string can also mean no code has been supplied. So it could be better treated as 'pass'.

In the second case:
 Error messages are meant to inform you of what you have done wrong so that you fix it. I think raising an Indentation error is far from what a user who is calling that method would be expecting, it does not help them at-all.

In the third case:
Supplying an empty string to timeit directly in bash ```python -m timeit '' ``` raises no such error. so we could say that fixing this will align the behavior in the two ways the function is run to be the same.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40670>
_______________________________________


More information about the Python-bugs-list mailing list