473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Internal Debugger Question

Hello,

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 !
Jul 18 '05 #1
4 2360
ll*****@web.de (Lothar Scholz) wrote in
news:6e**************************@posting.google.c om:
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 du****@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?
Jul 18 '05 #2
Duncan Booth <du****@NOSPAMrcp.co.uk> wrote in message news:<Xn***************************@127.0.0.1>...
ll*****@web.de (Lothar Scholz) wrote in
news:6e**************************@posting.google.c om:
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.


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.
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.


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.
Jul 18 '05 #3
ll*****@web.de (Lothar Scholz) writes:
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 !


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.

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
Jul 18 '05 #4
In article <7h*************@pc150.maths.bris.ac.uk>,
Michael Hudson <mw*@python.net> wrote:
ll*****@web.de (Lothar Scholz) writes:
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 !


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.


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
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Derek Goto | last post by:
I was running the perl debugger with arguments "-d -e 1" to test a small program. When I assigned a value to the variable $foo, I could use it fine, but when I qualified $bar with my, it remained...
30
by: Neil Zanella | last post by:
Hello, Allow me to share my frustrations with GNU g++. This is the second time something similar happens to me: I can't find anything wrong with my C++ program and yet I get segfaults, and...
65
by: Pmb | last post by:
I'm confused as to what the compiler error message I'm getting is refering to. Can someone take a gander and let me know what I did wrong? The program is below. When I compile it I get the...
1
by: Susanne Christe | last post by:
Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Registeresd JIT debugger is not avaialble: After executing an application I get the Error: ...
0
by: Saradhi | last post by:
Here I am back with the same question again. I am trying to attach my process to the .NET Debugger to debug my process. and I am using the folliwng code. if (...
1
by: Bill Menees | last post by:
VS.NET 2003 defaults the "Debugger Type" property to "Auto" for Visual C++ projects. Unfortunately, the "Auto" type isn't very smart. "Auto" bases the debugger type on the launched EXE's type,...
9
by: JT | last post by:
Here is the overall structure I will be referring to: End-program ProvideWorkFlow.dll Forms and methods that properly manipulate calls to methods in AccessUtils AccessUtils (a web service)...
12
by: Zytan | last post by:
Can I break the debugger into a worker thread? Right now, my app is freezing, and when I press pause, it stops on: Application.Run(new MyForm()); I don't know what that means. I know the...
7
by: colin | last post by:
Hi, Ive written a 3dmodel editor, and it works fairly well it harldy uses any cpu exept when its loading a texture from bitmap in the debugger, at all other times it hardly uses any cpu but from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.