classification
Title: 2to3: fix_future conflicts with fix_print
Type: behavior Stage: needs patch
Components: 2to3 (2.x to 3.x conversion tool) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alexandre.vassalotti, benjamin.peterson, r.david.murray
Priority: normal Keywords:

Created on 2009-07-06 17:13 by alexandre.vassalotti, last changed 2009-07-12 17:07 by benjamin.peterson. This issue is now closed.

Messages (3)
msg90183 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-07-06 17:13
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.
msg90352 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-09 20:26
See also issue 2412, which might or might not have a relevant patch.
msg90452 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-07-12 17:07
Fixed in r73981.
History
Date User Action Args
2009-07-12 17:07:02benjamin.petersonsetstatus: open -> closed
resolution: fixed
messages: + msg90452
2009-07-09 20:26:51r.david.murraysetnosy: + r.david.murray
messages: + msg90352
2009-07-09 20:25:26r.david.murraylinkissue6451 superseder
2009-07-06 17:13:14alexandre.vassalotticreate