Merge lp:~mterry/python-distutils-extra/746565 into lp:python-distutils-extra

Proposed by Michael Terry
Status: Merged
Merged at revision: 247
Proposed branch: lp:~mterry/python-distutils-extra/746565
Merge into: lp:python-distutils-extra
Diff against target: 12 lines (+1/-1)
1 file modified
DistUtilsExtra/auto.py (+1/-1)
To merge this branch: bzr merge lp:~mterry/python-distutils-extra/746565
Reviewer Review Type Date Requested Status
Martin Pitt (community) Approve
Review via email: mp+55790@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

Thanks for this!

Do you have an example where the current code goes wrong? I'd like to add a test case for it.

review: Needs Information
Revision history for this message
Michael Terry (mterry) wrote :

Sure. Have the following code layout:

mymodule/
  __init__.py
  foo.py
  bar.py

In foo.py, have:

"""
from mymodule.bar import a
from bar import b
from . bar import c
"""

The first import was always correctly ignored (it detected mymodule as a provided module).

The second import is an implicit relative import that the current code will still have problems with, as my change does not affect that.

My change does fix the third import.

Revision history for this message
Martin Pitt (pitti) wrote :

Ah, thanks! I merged this together with a test case update which reproduces this.

I'll also try to fix the second case.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DistUtilsExtra/auto.py'
2--- DistUtilsExtra/auto.py 2011-03-15 20:58:51 +0000
3+++ DistUtilsExtra/auto.py 2011-03-31 16:52:55 +0000
4@@ -345,7 +345,7 @@
5 if __external_mod(alias.name, attrs):
6 imports.add(alias.name)
7 if isinstance(node, ast.ImportFrom):
8- if __external_mod(node.module, attrs):
9+ if node.level == 0 and __external_mod(node.module, attrs):
10 imports.add(node.module)
11 except SyntaxError, e:
12 sys.stderr.write('WARNING: syntax errors in %s: %s\n' % (file, str(e)))

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: