summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-03-06 20:39:59 (GMT)
committerGuido van Rossum <guido@python.org>2000-03-06 20:39:59 (GMT)
commite85c93f52109711f415e860ba41609ae22984d92 (patch)
treeee2d483a09e6df91f84555bdea7b9c0c1781d4dd
parent0c3208aa628f090ce5a3278e6e53fe89c952f1b0 (diff)
downloadcpython-e85c93f52109711f415e860ba41609ae22984d92.zip
cpython-e85c93f52109711f415e860ba41609ae22984d92.tar.gz
cpython-e85c93f52109711f415e860ba41609ae22984d92.tar.bz2
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.
-rwxr-xr-xLib/pdb.py36
1 files changed, 21 insertions, 15 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 2e45098..67387a9 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -329,29 +329,35 @@ class Pdb(bdb.Bdb, cmd.Cmd):
# code parse time. We don't want that, so all breakpoints
# set at 'def' statements are moved one line onward
if line[:3] == 'def':
- incomment = ''
+ 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)
if not line:
print 'end of file'
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
+ if brackets <= 0 and line[0] not in ('#','"',"'"):
+ break
return lineno
def do_enable(self, arg):