• Resolution of paths in tracebacks

    From Vishal Chandratreya@21:1/5 to All on Wed May 31 10:42:42 2023
    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 os module, for
    instance, does the following.
    $ ./python
    import os.path
    os.path.isabs('/home/..')
    True
    os.path.abspath('/home/..')
    '/'
    Either way: should the traceback display the path without redundant
    elements?

    I am using CPython 3.13.0a0 (595ffddb33e95d8fa11999ddb873d08e3565d2eb).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Grant Edwards@21:1/5 to Vishal Chandratreya on Wed May 31 09:25:11 2023
    On 2023-05-31, Vishal Chandratreya <vpaijc@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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)