Issue 17393: stdlib import mistaken for local by import_fixer (original) (raw)

Issue17393

Created on 2013-03-10 20:22 by lregebro, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16826 closed Romuald,2019-10-16 21:15
Messages (4)
msg183894 - (view) Author: Lennart Regebro (lregebro) Date: 2013-03-10 20:22
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``.
msg183925 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2013-03-11 04:34
This is the cause for #13317
msg183936 - (view) Author: Lennart Regebro (lregebro) Date: 2013-03-11 06:08
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. #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 #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. :-)
msg354801 - (view) Author: Romuald Brunet (Romuald) * Date: 2019-10-16 14:36
Confirming that this issue is still present on 3.8 (and working on a fix)
History
Date User Action Args
2022-04-11 14:57:42 admin set github: 61595
2021-10-20 23:06:48 iritkatriel set status: open -> closedsuperseder: Close 2to3 issues and list them hereresolution: wont fixstage: patch review -> resolved
2019-10-16 21:15:07 Romuald set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest16376>
2019-10-16 14:36:34 Romuald set messages: +
2019-10-16 14:35:42 Romuald set nosy: + Romuald
2014-02-04 01:28:04 ced set nosy: + ced
2013-03-11 06:08:03 lregebro set messages: +
2013-03-11 04:34:30 eric.araujo set nosy: + eric.araujomessages: +
2013-03-10 20:23:14 lregebro set type: behavior
2013-03-10 20:22:54 lregebro create