File paths printed in stack trace are where Python was built???

Discussion in 'Python' started by Roy Smith, Nov 29, 2008.

  1. Roy Smith

    Roy Smith Guest

    We distribute Python internally by building it in one place, and then
    distributing images of the entire install area to wherever it's
    needed. I just noticed something strange; when I got an error which
    caused a stack trace, the file paths in the printed stack trace refer
    to the directory where Python was built.

    Why is this? All other paths I can think of in Python are generated
    relative to where the binary is running, not where it was built. Is
    there a way to make the stacktraces point to where Python is running
    from, instead of where it was built?


    Traceback (most recent call last):
    File "tProcess.py", line 27, in test_t1
    server = subprocess.Popen(argv)
    File "/emc/chacoj2/src/clean/smarts/thirdparty/python/2.5.1/
    linux_rhAS40-x86-32/install/lib/python2.5/subprocess.py", line 593, in
    __init__
    errread, errwrite)
    File "/emc/chacoj2/src/clean/smarts/thirdparty/python/2.5.1/
    linux_rhAS40-x86-32/install/lib/python2.5/subprocess.py", line 1079,
    in _execute_child
    raise child_exception
    AttributeError: 'list' object has no attribute 'rfind'
    Roy Smith, Nov 29, 2008
    #1
    1. Advertising

  2. On Fri, 28 Nov 2008 19:22:11 -0800, Roy Smith wrote:

    > We distribute Python internally by building it in one place, and then
    > distributing images of the entire install area to wherever it's needed.
    > I just noticed something strange; when I got an error which caused a
    > stack trace, the file paths in the printed stack trace refer to the
    > directory where Python was built.


    My guess is that your build process generates the .pyc files, and that
    they include a reference to the source location at the time they were
    built. I bet that if you remove the .pyc files and let them get re-
    generated the problem will go away.

    > Is there a way to make the stacktraces point to where Python is
    > running from, instead of where it was built?


    But the stack trace doesn't point to where Python is running from, it
    points to where the module is. Since you're (probably) running from a
    compiled module, the location of the .pyc file is useless, and you need
    to know where the .py file is. But how can the .pyc file know where
    the .py file is at runtime unless it is cached at compile time? I suppose
    Python could use some sort of heuristic to guess, but that would be slow
    and error-prone.


    --
    Steven
    Steven D'Aprano, Nov 29, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noah
    Replies:
    5
    Views:
    752
  2. Rich Burridge
    Replies:
    0
    Views:
    424
    Rich Burridge
    Jul 25, 2006
  3. Jean-Paul Calderone

    Re: Python stack trace on blocked running script.

    Jean-Paul Calderone, Jul 25, 2006, in forum: Python
    Replies:
    0
    Views:
    630
    Jean-Paul Calderone
    Jul 25, 2006
  4. AbsolutG

    Local file paths showing in stack traces

    AbsolutG, Aug 27, 2008, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    625
    John Saunders
    Aug 28, 2008
  5. Ohad Lutzky

    Paths, gentleman, paths

    Ohad Lutzky, Nov 6, 2006, in forum: Ruby
    Replies:
    2
    Views:
    176
    David Vallner
    Nov 7, 2006
Loading...

Share This Page