New submission from Martin v. Löwis <mar...@v.loewis.de>:

The fragment

try:
    import cStringIO as StringIO
except ImportError:
    import StringIO
s=StringIO.StringIO()

gets rewritten to

try:
    import io as StringIO
except ImportError:
    import io
s=io.StringIO()

Unfortunately, that code fails to work: the first import succeeds,
actually binding StringIO; the name io is unbound and gives NameError.

Apparently, the fixer choses to replace all occurrences of StringIO with
io; it should extend this replacement to "as" clauses.

My work-around is to import as _StringIO in both cases, and then refer
to the module as _StringIO.

----------
components: 2to3 (2.x to 3.0 conversion tool)
messages: 79568
nosy: loewis
severity: normal
status: open
title: incorrect renaming in imports

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue4909>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to