[Python-checkins] CVS: python/dist/src/Lib pdb.py,1.42,1.43

Guido van Rossum guido@cnri.reston.va.us
Mon, 6 Mar 2000 15:40:02 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Lib
In directory eric:/projects/python/develop/guido/src/Lib

Modified Files:
	pdb.py 
Log Message:
Sjoerd Mullender:

When you set a breakpoint on a function with a multi-line argument
list, the breakpoint is actually set on the second line of the
arguments instead of the first line of the body.  This patch fixes
that.


Index: pdb.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Lib/pdb.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -r1.42 -r1.43
*** pdb.py	2000/02/04 15:39:30	1.42
--- pdb.py	2000/03/06 20:39:59	1.43
***************
*** 330,335 ****
  		# set at 'def' statements are moved one line onward
  		if line[:3] == 'def':
! 			incomment = ''
  			while 1:
  				lineno = lineno+1
  				line = linecache.getline(filename, lineno)
--- 330,353 ----
  		# set at 'def' statements are moved one line onward
  		if line[:3] == 'def':
! 			instr = ''
! 			brackets = 0
  			while 1:
+ 				skipone = 0
+ 				for c in line:
+ 					if instr:
+ 						if skipone:
+ 							skipone = 0
+ 						elif c == '\\':
+ 							skipone = 1
+ 						elif c == instr:
+ 							instr = ''
+ 					elif c == '#':
+ 						break
+ 					elif c in ('"',"'"):
+ 						instr = c
+ 					elif c in ('(','{','['):
+ 						brackets = brackets + 1
+ 					elif c in (')','}',']'):
+ 						brackets = brackets - 1
  				lineno = lineno+1
  				line = linecache.getline(filename, lineno)
***************
*** 338,356 ****
  					return 0
  				line = string.strip(line)
- 				if incomment:
- 					if len(line) < 3: continue
- 					if (line[-3:] == incomment):
- 						incomment = ''
- 					continue
  				if not line: continue	# Blank line
! 				if len(line) >= 3:
! 					if (line[:3] == '"""'
! 					    or line[:3] == "'''"):
! 						if line[-3:] == line[:3]:
! 							# one-line string
! 							continue
! 						incomment = line[:3]
! 						continue
! 				if line[0] != '#': break
  		return lineno
  
--- 356,362 ----
  					return 0
  				line = string.strip(line)
  				if not line: continue	# Blank line
! 				if brackets <= 0 and line[0] not in ('#','"',"'"):
! 					break
  		return lineno