This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ksriram
Recipients ksriram
Date 2018-12-02.10:11:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1543745512.2.0.788709270274.issue35375@psf.upfronthosting.co.za>
In-reply-to
Content
Suppose I have a file profile.py in the same directory as the file I am running (say test.py)

Let the contents of the files be:

profile.py:
raise Exception

test.py:
import cProfile

now if I run test.py

$ python test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import cProfile
  File "/usr/lib/python3.7/cProfile.py", line 10, in <module>
    import profile as _pyprofile
  File "/home/username/profile.py", line 1, in <module>
    raise Exception
Exception

The file profile.py in '/usr/lib/python3.7' should have been loaded. This would also happen if test.py imported a module or package which imported cProfile.

The only possible way of avoiding this problem completely is by ensuring that the name of any the python files don't match a builtin python file or the name of any installed package.

A python user can't be expected to know the name of every possible file in the Python standard library. Maybe the current working directory should be removed from sys.path when importing from within another module not in the same directory.
History
Date User Action Args
2018-12-02 10:11:52ksriramsetrecipients: + ksriram
2018-12-02 10:11:52ksriramsetmessageid: <1543745512.2.0.788709270274.issue35375@psf.upfronthosting.co.za>
2018-12-02 10:11:52ksriramlinkissue35375 messages
2018-12-02 10:11:51ksriramcreate