You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
stdlib import mistaken for local by import_fixer #61595
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2021-10-20.23:06:48.722>created_at=<Date2013-03-10.20:22:54.597>labels= ['type-bug', 'expert-2to3']
title='stdlib import mistaken for local by import_fixer'updated_at=<Date2021-10-20.23:06:48.721>user='https://github.com/regebro'
If you have a local folder (without an init.py, hence just a normal folder) with the same name as a non local module, the import statements of that module will assumed to be local and transformed from for example import datetime to from . import datetime.
Activity
regebro commentedon Mar 10, 2013
If you have a local folder (without an init.py, hence just a normal folder) with the same name as a non local module, the import statements of that module will assumed to be local and transformed from for example
import datetimetofrom . import datetime.merwok commentedon Mar 11, 2013
This is the cause for bpo-13317
regebro commentedon Mar 11, 2013
Not really, but they are related. The fixer looks for a local module, and if it finds it it will assume the import is local.
bpo-13317 is caused by it not finding the module, since it's not built and hence assuming it's a global import.
This bug, contrariwise, is cause by the fixer finding a folder, and therefore assuming it is a local import when it's not.
The fix for this is to check that the folder has an __init__.py. The fix for bpo-13317 is to build extensions before running 2to3.
Neither of them are huge problems since you can avoid both bugs but not using relative imports. :-)
romuald commentedon Oct 16, 2019
Confirming that this issue is still present on 3.8 (and working on a fix)