summaryrefslogtreecommitdiffstats
path: root/Objects/frameobject.c
diff options
context:
space:
mode:
authorJeffrey Yasskin <jyasskin@gmail.com>2009-05-20 17:57:57 (GMT)
committerJeffrey Yasskin <jyasskin@gmail.com>2009-05-20 17:57:57 (GMT)
commitc8d30fec16e8ed7708bddfad8af03728ae2b9e4d (patch)
treeb5a578e18254b37828d32350b3099fa96f4053ed /Objects/frameobject.c
parentcf4ad76a0a429f8cc548aa4dc1d20a37a1fb3fb6 (diff)
downloadcpython-c8d30fec16e8ed7708bddfad8af03728ae2b9e4d.zip
cpython-c8d30fec16e8ed7708bddfad8af03728ae2b9e4d.tar.gz
cpython-c8d30fec16e8ed7708bddfad8af03728ae2b9e4d.tar.bz2
Fix issue #1689458 by teaching frame_setlineno how to jump to the first line of
a code object.
Diffstat (limited to 'Objects/frameobject.c')
-rw-r--r--Objects/frameobject.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 5e54585..ad31fc5 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -140,20 +140,26 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
new_lineno);
return -1;
}
-
- /* Find the bytecode offset for the start of the given line, or the
- * first code-owning line after it. */
- PyString_AsStringAndSize(f->f_code->co_lnotab, &lnotab, &lnotab_len);
- addr = 0;
- line = f->f_code->co_firstlineno;
- new_lasti = -1;
- for (offset = 0; offset < lnotab_len; offset += 2) {
- addr += lnotab[offset];
- line += lnotab[offset+1];
- if (line >= new_lineno) {
- new_lasti = addr;
- new_lineno = line;
- break;
+ else if (new_lineno == f->f_code->co_firstlineno) {
+ new_lasti = 0;
+ new_lineno = f->f_code->co_firstlineno;
+ }
+ else {
+ /* Find the bytecode offset for the start of the given
+ * line, or the first code-owning line after it. */
+ PyString_AsStringAndSize(f->f_code->co_lnotab,
+ &lnotab, &lnotab_len);
+ addr = 0;
+ line = f->f_code->co_firstlineno;
+ new_lasti = -1;
+ for (offset = 0; offset < lnotab_len; offset += 2) {
+ addr += lnotab[offset];
+ line += lnotab[offset+1];
+ if (line >= new_lineno) {
+ new_lasti = addr;
+ new_lineno = line;
+ break;
+ }
}
}