Resolution of paths in tracebacks

Grant Edwards grant.b.edwards at gmail.com
Wed May 31 12:25:11 EDT 2023


On 2023-05-31, Vishal Chandratreya <vpaijc at gmail.com> wrote:
> When an exception occurs, the full path to the file from which it
> originates is displayed, but redundant elements are not removed. For
> instance:
> $ ./python ./foo
> Traceback (most recent call last):
>   File "/home/User/cpython/./foo", line 4, in <module>
>     a()
>   File "/home/User/cpython/./foo", line 3, in a
>     def a(): raise ValueError
> ValueError
> This happens because the function _Py_abspath (in Python/fileutils.c)
> appends relative_path_to_file to absolute_path_to_current_working_directory.
> Not sure if this should be treated as a bug, because the definition of
> 'absolute path' is not clear. Does it mean a path starting from the root
> directory, or a path without redundant elements?

The former:

  https://www.linuxfoundation.org/blog/blog/classic-sysadmin-absolute-path-vs-relative-path-in-linux-unix




More information about the Python-list mailing list