PythonWin mystery solved

Gerson Kurz gerson.kurz at t-online.de
Fri Dec 6 00:37:40 EST 2002


Several people have problems with Python 2.2.2 and Pythonwin -
pressing F5 = Debugger Go stops initially in debugger.py and not, as
in older versions, just runs the code until a breakpoint occurs.

I did some checking, and, alas, "its not a bug, its a feature". Read
C:\Python22\Doc\lib\module-pdb.html : the documentation says

"""
run(statement[, globals[, locals]]) 
Execute the statement (given as a string) under debugger control. The
debugger prompt appears before any code is executed;
"""

aka, the debugger is *supposed* to stop before anything else happens.
Actually, it did not in older versions and this was *fixed* in 2.2.2.
I found that this explains the story:

http://sourceforge.net/tracker/?func=detail&atid=105470&aid=210682&group_id=5470

Also note the quote 

"""
With my patch, it works as expected.
Furthermore, Mark's F5 command is documented to
"start the program in the debugger". It never did so.
With the patch, it does.
Let's bring it to the end it deserves.
"""

If after all this you still agree that it is a bug, rather than a
feature, then the most straightforward solution is a simple flag that
skips the initial breakpoint:

	def run(self, cmd,globals=None, locals=None, start_stepping =
1):
...
	self.is_initial_breakpoint = 1
...
	def stop_here(self, frame):
		if self.is_initial_breakpoint:
			self.is_initial_breakpoint = 0
			self.set_continue()			
			return 0

(in bdb.py). 

NOTE: This is a *hack*, its not the "official" solution, as there
seems to be no "offical bug". 






More information about the Python-list mailing list