Message74075
Create an empty directory with only 2 files, foo.py and bar.py, both
exactly 1 line:
foo.py:
|from bar import bar
bar.py:
|bar = "bar"
Running 2to3 results in the following patch for foo.py:
-from bar import bar
+from .bar import bar
However, the resulting foo.py fails to run - the 2 files are not in a
package, so we get:
| ValueError: Attempted relative import in non-package
Attaching a patch which checks there is an __init__.py in the same
directory as the files before it considers it a potential relative import. |
|
Date |
User |
Action |
Args |
2008-09-30 13:20:32 | mhammond | set | recipients:
+ mhammond |
2008-09-30 13:20:32 | mhammond | set | messageid: <1222780832.06.0.913683232517.issue4001@psf.upfronthosting.co.za> |
2008-09-30 13:20:30 | mhammond | link | issue4001 messages |
2008-09-30 13:20:30 | mhammond | create | |
|