This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients DahlitzFlorian, anthonypjshaw, edison.abahurire, remi.lapeyre, serhiy.storchaka, terry.reedy
Date 2020-05-23.06:02:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Let a wcs be a string consisting of only whitespace and comments.
compile(wcs, '', 'exec') treats wcs the same as 'pass'.
Hence, a file with only whitespace and comments is the same as 'pass'.
compile(wcs, '', 'single'), for whatever reason, raises
SyntaxError: unexpected EOF while parsing
To get around this, a wcs input into IDLE's Shell, compiles with 'single', is replaced with 'pass' in codeop._maybe_compile, line 76.  I presume the REPL does the same.

If one thinks of parameter stmt as a top-level statement (or statements), it is reasonable to expect '' to be the same as 'pass'.  If one knows that stmt will be embedded into a compound statement (whether 'while', 'for' or 'def' does not matter here) for repeated execution, then 'pass' is more obviously the minimal statement.

It would have been better if the parameter name were 'suite', as suites can never be only whitespace.  We cannot change this, but I suggest replacing

The constructor takes a statement to be timed, an additional statement used for setup, and a timer function. Both statements default to 'pass'; the timer function is platform-dependent (see the module doc string). stmt and setup may also contain multiple statements separated by ; or newlines, as long as they don’t contain multi-line string literals. 

with the shorter, clearer, and updated

The constructor takes suite of statement to be timed, an additional suite used for setup, and a timer function (default time.perf_counter). Both suites default to 'pass' and may not contain multi-line string literals.

Since 3.3, the default timer is platform-independent, at least from a user viewpoint, and not mentioned in timeit.__doc__.  Suites can always have multiple statments separated by ; and \n.  The only needed qualification is the default and the restriction.
Date User Action Args
2020-05-23 06:02:33terry.reedysetrecipients: + terry.reedy, serhiy.storchaka, anthonypjshaw, DahlitzFlorian, remi.lapeyre, edison.abahurire
2020-05-23 06:02:33terry.reedysetmessageid: <>
2020-05-23 06:02:33terry.reedylinkissue40670 messages
2020-05-23 06:02:32terry.reedycreate