summaryrefslogtreecommitdiffstats
path: root/Objects/codeobject.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-01-20 11:16:21 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-01-20 11:16:21 (GMT)
commitf3914eb16d28ad9eb20fe5133d9aa83658bcc27f (patch)
tree65316948bcac4a6bf79e8b3791de51f11a163432 /Objects/codeobject.c
parent316fcc867bbae652272aefb726185c12907ba8d4 (diff)
downloadcpython-f3914eb16d28ad9eb20fe5133d9aa83658bcc27f.zip
cpython-f3914eb16d28ad9eb20fe5133d9aa83658bcc27f.tar.gz
cpython-f3914eb16d28ad9eb20fe5133d9aa83658bcc27f.tar.bz2
co_lnotab supports negative line number delta
Issue #26107: The format of the co_lnotab attribute of code objects changes to support negative line number delta. Changes: * assemble_lnotab(): if line number delta is less than -128 or greater than 127, emit multiple (offset_delta, lineno_delta) in co_lnotab * update functions decoding co_lnotab to use signed 8-bit integers - dis.findlinestarts() - PyCode_Addr2Line() - _PyCode_CheckLineNumber() - frame_setlineno() * update lnotab_notes.txt * increase importlib MAGIC_NUMBER to 3361 * document the change in What's New in Python 3.6 * cleanup also PyCode_Optimize() to use better variable names
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r--Objects/codeobject.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index b0e3446..0f03dfe 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -557,7 +557,8 @@ PyCode_Addr2Line(PyCodeObject *co, int addrq)
addr += *p++;
if (addr > addrq)
break;
- line += *p++;
+ line += (signed char)*p;
+ p++;
}
return line;
}
@@ -592,17 +593,19 @@ _PyCode_CheckLineNumber(PyCodeObject* co, int lasti, PyAddrPair *bounds)
if (addr + *p > lasti)
break;
addr += *p++;
- if (*p)
+ if ((signed char)*p)
bounds->ap_lower = addr;
- line += *p++;
+ line += (signed char)*p;
+ p++;
--size;
}
if (size > 0) {
while (--size >= 0) {
addr += *p++;
- if (*p++)
+ if ((signed char)*p)
break;
+ p++;
}
bounds->ap_upper = addr;
}