[New-bugs-announce] [issue22606] Inconsistency between Python 2 and PyPy regarding future imports

Claudiu Popa report at bugs.python.org
Fri Oct 10 22:48:45 CEST 2014


New submission from Claudiu Popa:

Hi,

The following code gives similar errors for both PyPy and Python 2 when called, but totally different AST objects.

Given the following code, PyPy says that `print(4)` is an _ast.Print, while Python 2 believes that it is an _ast.Expr (which wraps a Call). This behaviour is wrong, Python 2 shouldn't extrapolate further if the __future__ is misplaced.


   from ast import parse

   bad = """
   a = 1
   from __future__ import print_function
   print(4)
   """

   x = parse(bad)
   print(x.body[2])

Brett, I added you on this as nosy, since I discovered this bug while debugging your print-statement pull request, so I thought you should know. :-)

----------
messages: 229037
nosy: Claudiu.Popa, brett.cannon
priority: normal
severity: normal
status: open
title: Inconsistency between Python 2 and PyPy regarding future imports
type: behavior
versions: Python 2.7

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


More information about the New-bugs-announce mailing list