| Index: Lib/compiler/pyassem.py |
| =================================================================== |
| --- Lib/compiler/pyassem.py (revision 70087) |
| +++ Lib/compiler/pyassem.py (working copy) |
| @@ -620,6 +620,11 @@ |
| # compute deltas |
| addr = self.codeOffset - self.lastoff |
| line = lineno - self.lastline |
| + abs_line = abs(line) |
| + if line >= 0: |
| + sign_line = lambda l: l |
| + else: |
| + sign_line = lambda l: 256 - l |
| # Python assumes that lineno always increases with |
| # increasing bytecode address (lnotab is unsigned char). |
| # Depending on when SET_LINENO instructions are emitted |
| @@ -630,19 +635,18 @@ |
| # after the loading of "b". This works with the C Python |
| # compiler because it only generates a SET_LINENO instruction |
| # for the assignment. |
| - if line >= 0: |
| - push = self.lnotab.append |
| - while addr > 255: |
| - push(255); push(0) |
| - addr -= 255 |
| - while line > 255: |
| - push(addr); push(255) |
| - line -= 255 |
| - addr = 0 |
| - if addr > 0 or line > 0: |
| - push(addr); push(line) |
| - self.lastline = lineno |
| - self.lastoff = self.codeOffset |
| + push = self.lnotab.append |
| + while addr > 255: |
| + push(255); push(0) |
| + addr -= 255 |
| + while abs_line > 127: |
| + push(addr); push(sign_line(127)) |
| + abs_line -= 127 |
| + addr = 0 |
| + if addr > 0 or abs_line > 0: |
| + push(addr); push(sign_line(abs_line)) |
| + self.lastline = lineno |
| + self.lastoff = self.codeOffset |
| def getCode(self): |
| return ''.join(self.code) |