Mailing List Archive

[issue3994] import fixer misses some symbols
New submission from Mark Hammond <mhammond@users.sourceforge.net>:

The following source file:
"""
import _winreg
_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "foo")
"""

results in the following "patch":

-import _winreg
-_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "foo")
+import winreg
+winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "foo")

Note the first param has not been converted correctly. This is probably
due to it following the paren, as using the same symbol in a local
variable works correctly.

----------
components: 2to3 (2.x to 3.0 conversion tool)
messages: 74014
nosy: mhammond
priority: high
severity: normal
status: open
title: import fixer misses some symbols
type: behavior

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue3994>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue3994] import fixer misses some symbols [ In reply to ]
Changes by Benjamin Peterson <musiccomposition@gmail.com>:


----------
nosy: +nedds

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue3994>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue3994] import fixer misses some symbols [ In reply to ]
Nick Edds <nedds@uchicago.edu> added the comment:

I'll look in to it. Just give me a couple of days.

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue3994>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue3994] import fixer misses some symbols [ In reply to ]
Nick Edds <nedds@uchicago.edu> added the comment:

The problem is that fix_imports doesn't look at matches that are nested
within matches. So the _winreg.OpenKey part gets fixed, but the
_winreg.HKEY_LOCAL_MACHINE does not because it is nested within the
other node. I didn't make fix_imports so I don't know what the intention
was for not matching nested matches. When I removed that restriction,
the fixer works as expected. It also does not cause any of 2to3's tests
to fail nor does it have a noticeable impact on 2to3's runtime, so I'm
tempted to say that this is the fix to make, but I don't want to commit
to it until I've heard from it's author about it. I added Collin to the
Nosy List, so hopefully he can comment on the reasoning behind the
restriction.

----------
nosy: +collinwinter

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue3994>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com
[issue3994] import fixer misses some symbols [ In reply to ]
Nick Edds <nedds@uchicago.edu> added the comment:

Here is a patch with a new test case. I don't know if we should apply it
until we've heard from Collin though. The old version of fix_imports
fails the new test, but this version, which allows matching of nodes
nested within matches, passes the new test I added for nesting, as well
as all of the other 2to3 tests.

----------
keywords: +patch
Added file: http://bugs.python.org/file11756/fix_imports_bug.diff

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue3994>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com