[Compiler-sig] AST: jump offsets wrong when EXTENDED_ARG is used

Neal Norwitz nnorwitz at gmail.com
Mon Oct 24 03:34:39 CEST 2005


On 10/23/05, Neil Schemenauer <nas at arctrix.com> wrote:
>
> I wonder if the old compiler and the compiler package get this right.

Minor variation on Armins code (move the %s from before the loop to
inside the loop):

longexpr = 'x = x or ' + '-x' * 2500
code = '''
def f(x):
    while x:
        %s
        %s
        %s
        %s
        %s
        %s
        %s
        %s
        %s
        %s
        x -= 1
        # EXTENDED_ARG/JUMP_ABSOLUTE here
    return x
''' % ((longexpr,)*10)

exec code
f(5)

Works in CVS (at least it seems to work), but in 2.4 produces:
  SystemError: com_backpatch: offset too large


More information about the Compiler-sig mailing list