[New-bugs-announce] [issue8505] 2to3 fix_future.py removes __future__ imports, but should it?

Barry A. Warsaw report at bugs.python.org
Fri Apr 23 14:31:15 CEST 2010


New submission from Barry A. Warsaw <barry at python.org>:

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?

----------
components: 2to3 (2.x to 3.0 conversion tool)
messages: 104008
nosy: barry
severity: normal
status: open
title: 2to3 fix_future.py removes __future__ imports, but should it?
versions: Python 3.1, Python 3.2

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


More information about the New-bugs-announce mailing list