Serhiy Storchaka <[email protected]> added the comment:
Accepting an empty string in CLI is just an artifact of the implementation.
There was no intention to support it. It will fail if pass a space:
./python -m timeit ' '
or two empty arguments:
IndentationError:
./python -m timeit '' ''
I do not see this is an issue. Garbage in -- garbage out. IndentationError is a
subclass of SyntaxError, so if you handle it programmatically, it does not
matter.
Of course we try to catch some user errors and provide informative traceback.
timeit now correctly handles most of code which interferes with the control
flow in functions and loops: 'return', 'yield', 'break', 'await'.
But it is still possible to bypass the validation. For example:
./python -m timeit -s 'while False:' -s ' pass' ' break'
I think there is an infinite number of ways to fool timeit. And an empty string
is just one of them, not special enough to add a special handling in the code.
----------
nosy: +serhiy.storchaka
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40670>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com