Internal Debugger Question

Duncan Booth duncan at NOSPAMrcp.co.uk
Fri Sep 12 11:09:00 EDT 2003


llothar at web.de (Lothar Scholz) wrote in 
news:6ee58e07.0309120604.3a1f4985 at posting.google.com:

> i'm currently writing a debugger for python and found that some
> modules store an absolute file path in "co_filename" 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 !

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 at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?




More information about the Python-list mailing list