Git Product home page Git Product logo

Comments (5)

MatthieuDartiailh avatar MatthieuDartiailh commented on August 19, 2024 1

Always happy to help !

from bytecode.

MatthieuDartiailh avatar MatthieuDartiailh commented on August 19, 2024

Just to help me follow could you post some equivalent code/pseudo-code ?

from bytecode.

P403n1x87 avatar P403n1x87 commented on August 19, 2024

This is an async_generator wrapper. This should be close to the following Python code

async def w(g):
    c = g.__anext__
    while True:
        _ = c()
        try:
            _ = await _
        except StopAsyncIteration:
            return
        try:
            s = yield _
        except GeneratorExit:
            await g.aclose()
        except:
            await g.athrow(*sys.exc_info())
        c = lambda: g.asend(s)

from bytecode.

MatthieuDartiailh avatar MatthieuDartiailh commented on August 19, 2024

Can you also explicit your two functions compare_exc and pop_jump_if_false, so that I know what the bytecode looks for both versions ?

from bytecode.

P403n1x87 avatar P403n1x87 commented on August 19, 2024

Big facepalm moment! Your last question helped me find the actual issue, which was due to copy-pasta in my code! 😢 These are the functions

    def compare_exc(label, lineno):
        return (
            Instr("COMPARE_OP", Compare.EXC_MATCH, lineno=lineno)
            if PY < (3, 9)
            else Instr("JUMP_IF_NOT_EXC_MATCH", label, lineno=lineno)
        )

    def jump_if_false(label, lineno):
        return Instr("POP_JUMP_IF_FALSE", label, lineno=lineno) if PY < (3, 9) else Instr("NOP", lineno=lineno)

which are defined locally inside another function. I had exc in place of label in jump_if_false. So indeed the generated bytecode was correct as it was getting exc from the outer scope! 😭 . Now that gives me RuntimeError: Failed to compute stacksize, got negative size but I should be able to fix this.

Apologies for this non-issue!

from bytecode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.