classification
Title: Add sys flag to always show full paths in stack traces (instead of relative paths)
Type: enhancement Stage:
Components: Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Scott Arciszewski, steven.daprano, xtreak
Priority: normal Keywords:

Created on 2018-12-27 15:50 by Scott Arciszewski, last changed 2018-12-28 12:05 by xtreak.

Messages (2)
msg332593 - (view) Author: Scott Arciszewski (Scott Arciszewski) Date: 2018-12-27 15:50
I have a wsgi script writing to a log file. The contents look like this (truncated):

  File "build/bdist.linux-x86_64/egg/trac/ticket/query.py", line 284, in _count
    % sql, args)[0][0]
  File "build/bdist.linux-x86_64/egg/trac/db/api.py", line 122, in execute
    return db.execute(query, params)
  File "build/bdist.linux-x86_64/egg/trac/db/util.py", line 128, in execute
    cursor.execute(query, params if params is not None else [])

When confronted with this logfile, I have no idea where build/bdist.linux-x86_64 lives. Rather than hoping a well-timed lsof is adequate to catch the actual script path, I'd like to be able to set a sys.flag to always log the real, fullpath of the .py script either instead of, or alongside, the file path.
msg332622 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2018-12-27 21:51
Python 2.7 is (almost) end of life and well beyond feature-freeze, so this can only go into 3.8 or better.

Since the paths logged are relative to the current working directory, perhaps you could just have your script log the working directory?
History
Date User Action Args
2018-12-28 12:05:04xtreaksetnosy: + xtreak
2018-12-27 21:51:48steven.dapranosetversions: - Python 2.7
nosy: + steven.daprano

messages: + msg332622

type: enhancement
2018-12-27 15:50:03Scott Arciszewskicreate