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.

classification
Title: exec string fails with trailing whitespace
Type: Stage:
Components: Interpreter Core Versions: Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, ericp, r.david.murray
Priority: normal Keywords:

Created on 2010-10-26 19:21 by ericp, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg119640 - (view) Author: Eric Promislow (ericp) Date: 2010-10-26 19:21
The following code throws an exception in Python 3.1 (and 3.2 alpha),
but runs with 2.x:

>>> exec('if True:\n    print("Hello")\n    \n    ')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 4

SyntaxError: invalid syntax
>>>

This is with Python 3.1.1.2, but I can repro it with a 3.2 alpha
as well.

Ref Komodo bug http://bugs.activestate.com/show_bug.cgi?id=88566
msg119644 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-10-26 19:49
I can reproduce this on 3.1 but not py3k trunk.
msg119647 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-10-26 20:33
That's because it's fixed.
msg119650 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-10-26 21:04
The fix is not something that can be backported to 3.1?  (This is a regression relative to 2.x).
msg119653 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-10-26 21:59
2010/10/26 R. David Murray <report@bugs.python.org>:
>
> R. David Murray <rdmurray@bitdance.com> added the comment:
>
> The fix is not something that can be backported to 3.1?  (This is a regression relative to 2.x).

No, it's not. The fix was a bit of "feature", so it was in 2.7 and py3k.
msg119671 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-10-27 02:49
I thought I tested this on 2.6, but I forgot that my system has now made 2.7 the default python.  And now that you mention it, I vaguely remember this feature getting added.  Sorry for the noise.
History
Date User Action Args
2022-04-11 14:57:07adminsetgithub: 54413
2010-10-27 02:49:11r.david.murraysetmessages: + msg119671
2010-10-26 21:59:42benjamin.petersonsetmessages: + msg119653
2010-10-26 21:04:33r.david.murraysetmessages: + msg119650
2010-10-26 20:33:37benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg119647
2010-10-26 19:49:35r.david.murraysetnosy: + r.david.murray, benjamin.peterson
messages: + msg119644
2010-10-26 19:21:17ericpcreate