[issue6429] 2to3: fix_future conflicts with fix_print

Alexandre Vassalotti report at bugs.python.org
Mon Jul 6 19:13:15 CEST 2009


New submission from Alexandre Vassalotti <alexandre at peadrop.com>:

Running 2to3 with the default options on the following code:

  from __future__ import print_function
  x,y = 1,2
  print(x, y)

produces the following diff:

  --- future_print.py (original)
  +++ future_print.py (refactored)
  @@ -1,5 +1,5 @@
  -from __future__ import print_function
  +
  
   x = 1
   y = 2
  -print(x, y)
  +print((x, y))

If the "--nofix=future" options is specified, 2to3 produces the correct
output.

I found this while working on a fixer for removing future_builtins
imports. It seems that fixer_util.does_tree_import() is unable to find
the __future__ import node and thus causes FixPrint to be run instead of
being skipped.

----------
components: 2to3 (2.x to 3.0 conversion tool)
messages: 90183
nosy: alexandre.vassalotti, benjamin.peterson
priority: normal
severity: normal
stage: needs patch
status: open
title: 2to3: fix_future conflicts with fix_print
type: behavior

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


More information about the Python-bugs-list mailing list