[issue3370] importing with_statement causes exec to raise syntax error on block that doesn't end with a newline

Matt McCredie report at bugs.python.org
Wed Jul 16 00:20:36 CEST 2008


New submission from Matt McCredie <mccredie at gmail.com>:

The following session demonstrates the issue:

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exec "def foo():\n    return 0" # no ending newline works fine
>>> foo()
0
>>> exec "def foo():\n    return 1\n" # with an ending newline works fine
>>> foo()
1
>>> from __future__ import with_statement
>>> exec "def foo():\n    return 2\n" # with an ending newline works fine
>>> foo()
2
>>> exec "def foo():\n    return 3" # without an ending new line... breaks

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 2
    return 3
          ^ 


Possibly related to http://bugs.python.org/issue1184112, and/or
http://bugs.python.org/issue501622?

----------
components: Interpreter Core
messages: 69723
nosy: mccredie
severity: normal
status: open
title: importing with_statement causes exec to raise syntax error on block that doesn't end with a newline
versions: Python 2.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3370>
_______________________________________


More information about the Python-bugs-list mailing list