MatthieuDartiailh/bytecode

Why are extended line offsets -127 and 126, and not -128 and 127?

Closed this issue · 2 comments

Regarding this part here, emitting extended line offsets:
https://github.com/vstinner/bytecode/blob/master/bytecode/concrete.py#L289-L295

But CPython uses -128 and 127 as the range, which is the (inclusive) range of a signed byte:
https://github.com/python/cpython/blob/3.9/Python/compile.c#L5638-L5648

The dis module too treats them as signed bytes:
https://github.com/python/cpython/blob/master/Lib/dis.py#L472-L474

Thanks for your report. I do not think I ever touched this part of the codebase but it does sound like a bug. Would you mind putting together a PR ?