[issue46806] Overlapping PYTHONPATH may cause import already imported module

2022-02-27 Thread aklajnert
aklajnert added the comment: Honestly, it seems to me that the documents that you mentioned are discussing different problems, that may be related, but are not the same as the one I've described here. I'm not arguing - you're clearly more experienced and that's not my area of expertise,

[issue46806] Overlapping PYTHONPATH may cause import already imported module

2022-02-23 Thread Eric Snow
Eric Snow added the comment: FYI, a technical solution has been discussed before: bpo-13475 and PEP 395. However, that does not help so much if the default behavior isn't changed. That would require a PEP but I expect it would be rejected because so many scripts already rely on the

[issue46806] Overlapping PYTHONPATH may cause import already imported module

2022-02-22 Thread aklajnert
aklajnert added the comment: I agree that adding a package directory to PYTHONPATH is not a good idea, however, I've stumbled on it in two completely independent companies' codebases. So it makes me suspect that this is may not be that rare case. In the previous company we got bitten by

[issue46806] Overlapping PYTHONPATH may cause import already imported module

2022-02-22 Thread Eric Snow
Eric Snow added the comment: I'm leaving this "pending" in case there may be some improvement we can make to the documentation to address this. -- components: +Interpreter Core nosy: +docs@python status: open -> pending ___ Python tracker

[issue46806] Overlapping PYTHONPATH may cause import already imported module

2022-02-22 Thread Eric Snow
Eric Snow added the comment: Here is more detail on what happens when "from src import user_1, user_2, user_3" is executed in main.py: 1. the "src" module is imported a. not found in sys.modules b. file found on a sys.path entry (the directory main.py is in) c. the "src" module is

[issue46806] Overlapping PYTHONPATH may cause import already imported module

2022-02-22 Thread Eric Snow
Eric Snow added the comment: When you run a Python script, the directory the script is in is automatically added to the beginning of sys.path. This is the fundamental issue you've run into. Basically, "src.common_object" is imported relative to the "src" that was imported relative to that

[issue46806] Overlapping PYTHONPATH may cause import already imported module

2022-02-20 Thread aklajnert
Change by aklajnert : -- title: Overlapping PYTHONPATH may cause -> Overlapping PYTHONPATH may cause import already imported module ___ Python tracker ___