Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.9 compatibility #51372

Open
2 tasks
xmo-odoo opened this issue May 18, 2020 · 0 comments
Open
2 tasks

Python 3.9 compatibility #51372

xmo-odoo opened this issue May 18, 2020 · 0 comments
Assignees

Comments

@xmo-odoo
Copy link
Collaborator

Python 3.9 is not exactly there yet, but this can serve as a reminder of things to come:

  • COMPARE_OP split into 4 opcodes (python/cpython@9af0e47)

  • LOAD_ASSERTION_ERROR bytecode for assert statements

    assert is compiled to a simple conditional:

     >>> @dis.dis
     ... def foo(): 
     ...     assert a
     ... 
       3           0 LOAD_GLOBAL              0 (a)
                   2 POP_JUMP_IF_TRUE         8
                   4 LOAD_GLOBAL              1 (AssertionError)
                   6 RAISE_VARARGS            1
             >>    8 LOAD_CONST               0 (None)
                  10 RETURN_VALUE
     >>> @dis.dis
     ... def foo():
     ...     if not a:
     ...             raise AssertionError
     ... 
       3           0 LOAD_GLOBAL              0 (a)
                   2 POP_JUMP_IF_TRUE         8
     
       4           4 LOAD_GLOBAL              1 (AssertionError)
                   6 RAISE_VARARGS            1
             >>    8 LOAD_CONST               0 (None)
                  10 RETURN_VALUE
    

    however in order to ensure it can always properly load AssertionError at runtime, in 3.9 it gets a dedicated opcode for this. Check if we have assertions in safe-eval'd code and add the opcode if so.

@xmo-odoo xmo-odoo self-assigned this May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant