Menu

#218 Hyperlink relative pathnames in console output

open
nobody
None
5
2007-03-26
2007-03-26
scorley
No

Sometimes, a module's pathname is a relative pathname in the console, and is not hyperlinked.

For example, if a script from C:\projectname loads some modules from C:\projectname\module1\submodule2, the traceback might contain 'File: "module1\submodule2\somefile.py"'

Relative pathnames appear to be used when Python is run from a particular working directory, and modules are imported from packages located in that working directory.

It seems that prepending the base directory from the current debug profile would make these relative pathnames resolve correctly.

To recreate a relative pathname example, you can do the following:

In some directory, say /temp, create a directory called "testpkg". Inside testpkg, create an empty __init__.py file and a file called "errormod.py" with one line, "assert False".

So you have:
/temp/testpkg/__init__.py
/temp/testpkg/errormod.py

Then change the working directory back to /temp, start the python cli from /temp and import errormod:

>>> import testpkg.errormod
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "testpkg\errormod.py", line 1, in <module>
assert False
AssertionError
>>>

The relative pathname above is "testpkg\errormod.py" and will not be hyperlinked in the current pydev console.

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.