msg104008 - (view) |
Author: Barry A. Warsaw (barry) *  |
Date: 2010-04-23 12:31 |
Lines such as the following are removed by fix_future.py in 2to3 from __future__ import absolute_import, unicode_literals I think this is unnecessary and I have a case where it causes problems. It's unnecessary because this import is essentially a no-op in Python 3, so it does no harm, and serves no actual useful purpose to remove. It causes harm because of a common idiom in doctest setups: def setup(testobj): """Test setup.""" # Make sure future statements in our doctests match the Python code. testobj.globs['absolute_import'] = absolute_import testobj.globs['unicode_literals'] = unicode_literals fix_future.py removes the import so these cause NameErrors. Sure, I can wrap them in try/excepts, but still what's the point of fix_future? |
|
|
msg104049 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2010-04-23 20:39 |
You can just turn off fix_future with -x future. |
|
|
msg104104 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2010-04-24 17:10 |
I think the unnecessary removal of __future__ imports but consistent with the idea that Python 3 is a new start, a blank sheet, and we don’t mention every novelty since previous versions. |
|
|
msg104105 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2010-04-24 17:12 |
s/but/is/ |
|
|
msg104123 - (view) |
Author: Barry A. Warsaw (barry) *  |
Date: 2010-04-24 19:27 |
Removing __future__ as part of explicit command line execution of 2to3 makes some sense, but I wonder if 2to3 is used more often automatically (e.g. via Distribute) where it's at best unhelpful. 2to3 is all about making it easy to port code from Python 2 to 3, and this particular transformation makes it (albeit, slightly so) harder. A different idea would be to add a comment before the future import indicating its uselessness, but not removing it. OTOH, I would also be happy with a better way to just disable it in a setup.py (e.g. by passing the -x flag in somehow). |
|
|
msg104124 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2010-04-24 19:29 |
2010/4/24 Barry A. Warsaw <report@bugs.python.org>: > > Barry A. Warsaw <barry@python.org> added the comment: > > Removing __future__ as part of explicit command line execution of 2to3 makes some sense, but I wonder if 2to3 is used more often automatically (e.g. via Distribute) where it's at best unhelpful. 2to3 is all about making it easy to port code from Python 2 to 3, and this particular transformation makes it (albeit, slightly so) harder. It's also designed to be easily customizable. > > A different idea would be to add a comment before the future import indicating its uselessness, but not removing it. OTOH, I would also be happy with a better way to just disable it in a setup.py (e.g. by passing the -x flag in somehow). I'm not sure we should get into the habit of telling people that their code is useless. :) I'll just close this as won't fix. |
|
|
msg104125 - (view) |
Author: Barry A. Warsaw (barry) *  |
Date: 2010-04-24 19:34 |
Since the workaround is easy enough, I won't push for this. I still think it's an unhelpful transformation. |
|
|