Internal Debugger Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lothar Scholz

    Internal Debugger Question

    Hello,

    i'm currently writing a debugger for python and found that some
    modules store an absolute file path in "co_filenam e" of there
    methods/functions and some store a relative file path. Because the
    relative file path can never be expanded to an absolute file path
    later (the sys.path may have changed) it is impossible to find the
    source code location.

    Is there anything i have missed or is this simply a bug. I would
    highly recommend to fix this bug !
  • Duncan Booth

    #2
    Re: Internal Debugger Question

    llothar@web.de (Lothar Scholz) wrote in
    news:6ee58e07.0 309120604.3a1f4 985@posting.goo gle.com:
    [color=blue]
    > i'm currently writing a debugger for python and found that some
    > modules store an absolute file path in "co_filenam e" of there
    > methods/functions and some store a relative file path. Because the
    > relative file path can never be expanded to an absolute file path
    > later (the sys.path may have changed) it is impossible to find the
    > source code location.
    >
    > Is there anything i have missed or is this simply a bug. I would
    > highly recommend to fix this bug ![/color]

    Are you running Python 2.3, if not you should upgrade as the behaviour has
    changed? The only relative paths I can see are for the script itself. Other
    modules, even when loaded through a relative path store the absolute value
    of the name.

    Before trying to use the stored filename, remember that as of Python 2.3
    you can have custom loaders, so the 'filename' might not refer to a path at
    all (although the loader might have a get_source method to help you).

    Even if it does refer to a path, the path might not be valid when you come
    to use it, if for example it was a path to a network drive which is no
    longer accessible. I think the best you can do in this situation is to try
    to use the path information you are given, and if you can't find a suitable
    source file either prompt the user or just give up.

    --
    Duncan Booth duncan@rcp.co.u k
    int month(char *p){return(1248 64/((p[0]+p[1]-p[2]&0x1f)+1)%12 )["\5\x8\3"
    "\6\7\xb\1\x9\x a\2\0\4"];} // Who said my code was obscure?

    Comment

    • Lothar Scholz

      #3
      Re: Internal Debugger Question

      Duncan Booth <duncan@NOSPAMr cp.co.uk> wrote in message news:<Xns93F4A2 93A97B6duncanrc pcouk@127.0.0.1 >...[color=blue]
      > llothar@web.de (Lothar Scholz) wrote in
      > news:6ee58e07.0 309120604.3a1f4 985@posting.goo gle.com:
      >[color=green]
      > > i'm currently writing a debugger for python and found that some
      > > modules store an absolute file path in "co_filenam e" of there
      > > methods/functions and some store a relative file path. Because the
      > > relative file path can never be expanded to an absolute file path
      > > later (the sys.path may have changed) it is impossible to find the
      > > source code location.
      > >
      > > Is there anything i have missed or is this simply a bug. I would
      > > highly recommend to fix this bug ![/color]
      >
      > Are you running Python 2.3, if not you should upgrade as the behaviour has
      > changed? The only relative paths I can see are for the script itself. Other
      > modules, even when loaded through a relative path store the absolute value
      > of the name.[/color]

      Yes i'm using Python 2.3 and Webware on Win32. As far as i have seen
      it there is no custom loader in Webware but the paths for all the base
      classes are relative paths. The path for user defined Python Server
      Pages and Servelets are absolute - this is the strange thing. I
      remember that there was a problem with 2.2 so i hoped all this was
      gone.
      [color=blue]
      > Even if it does refer to a path, the path might not be valid when you come
      > to use it, if for example it was a path to a network drive which is no
      > longer accessible. I think the best you can do in this situation is to try
      > to use the path information you are given, and if you can't find a suitable
      > source file either prompt the user or just give up.[/color]

      Yes but i don't think anyone change network drives when debugging an
      application. And if the network has problems it is time for a cup of
      coffee instead of further debugging.

      Comment

      • Michael Hudson

        #4
        Re: Internal Debugger Question

        llothar@web.de (Lothar Scholz) writes:
        [color=blue]
        > i'm currently writing a debugger for python and found that some
        > modules store an absolute file path in "co_filenam e" of there
        > methods/functions and some store a relative file path. Because the
        > relative file path can never be expanded to an absolute file path
        > later (the sys.path may have changed) it is impossible to find the
        > source code location.
        >
        > Is there anything i have missed or is this simply a bug. I would
        > highly recommend to fix this bug ![/color]

        I belive this is one of the oldest open bug reports on SF... I spent a
        few minutes looking at it, before deciding I didn't care enough to fix
        it. Your point of view may be different:



        Be warned, the import code is some of the most frightening (to me,
        anyway) code in Python.

        Cheers,
        mwh

        --
        48. The best book on programming for the layman is "Alice in
        Wonderland"; but that's because it's the best book on
        anything for the layman.
        -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html

        Comment

        • Just

          #5
          Re: Internal Debugger Question

          In article <7h3r82gem0k.fs f@pc150.maths.b ris.ac.uk>,
          Michael Hudson <mwh@python.net > wrote:
          [color=blue]
          > llothar@web.de (Lothar Scholz) writes:
          >[color=green]
          > > i'm currently writing a debugger for python and found that some
          > > modules store an absolute file path in "co_filenam e" of there
          > > methods/functions and some store a relative file path. Because the
          > > relative file path can never be expanded to an absolute file path
          > > later (the sys.path may have changed) it is impossible to find the
          > > source code location.
          > >
          > > Is there anything i have missed or is this simply a bug. I would
          > > highly recommend to fix this bug ![/color]
          >
          > I belive this is one of the oldest open bug reports on SF... I spent a
          > few minutes looking at it, before deciding I didn't care enough to fix
          > it. Your point of view may be different:
          >
          > http://python.org/sf/415492
          >
          > Be warned, the import code is some of the most frightening (to me,
          > anyway) code in Python.[/color]

          A workaround may be to look at __file__ in the frame's f_globals field.
          I'm moderately confident that that one gets set correctly upon import.

          Just

          Comment

          Working...