[New-bugs-announce] [issue19510] lib2to3.fixes.fix_import gets confused if implicit relative imports and absolute imports are on the same line

Augie Fackler report at bugs.python.org
Wed Nov 6 01:27:39 CET 2013


New submission from Augie Fackler:

While tinkering (again) with Mercurial Python 3 messes, I ran across this gem:

import error, osutil, encoding, collections

(http://selenic.com/hg/file/e1317d3e59e1/mercurial/util.py#l17)

That import statement contains 3 relative imports (that is, mercurial.error, mercurial.osutil, and mercurial.encoding), and one standard library import (collections). Because of the standard lib import on that line, lib2to3 doesn't rewrite any of the imports. If I instead move collections to its own line, then the first three imports get correctly rewritten to the "from . import error" form.

I've got Python 3.3.2 locally, and the lib2to3 is the one from that stdlib.

----------
components: 2to3 (2.x to 3.x conversion tool)
messages: 202248
nosy: durin42, twouters
priority: normal
severity: normal
status: open
title: lib2to3.fixes.fix_import gets confused if implicit relative imports and absolute imports are on the same line
versions: Python 3.3

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


More information about the New-bugs-announce mailing list