Message330874
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. |
|
Date |
User |
Action |
Args |
2018-12-02 10:11:52 | ksriram | set | recipients:
+ ksriram |
2018-12-02 10:11:52 | ksriram | set | messageid: <1543745512.2.0.788709270274.issue35375@psf.upfronthosting.co.za> |
2018-12-02 10:11:52 | ksriram | link | issue35375 messages |
2018-12-02 10:11:51 | ksriram | create | |
|