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

pony.orm.decompiling.DecompileError: Unsupported operation: POP_JUMP_IF_NOT_NONE #725

Open
luup2k opened this issue Sep 11, 2024 · 3 comments

Comments

@luup2k
Copy link

luup2k commented Sep 11, 2024

Script Example on Python 3.12 and ponyorm 0.7.19:

from pony.orm import (
    Database,
    Required,
    Set,
    Optional,
    PrimaryKey,
    set_sql_debug,
    commit,
)
import pony.orm as pny

db = Database()
db.bind(provider="sqlite", filename=":memory:")


class Metric(db.Entity):
    id = PrimaryKey(int, auto=True)
    spec = Required(str)
    name = Optional(str, nullable=True)


db.generate_mapping(create_tables=True)

with pny.db_session:
    m1 = Metric(spec="MetricSpec1")
    commit()

    ident_value = "key"

    query_req = pny.select(
        (m.id, m.name, m.spec)
        for m in Metric
        if m.name == ident_value or m.name is None
    )

Output:

Traceback (most recent call last):
File "/app/pony_bug.py", line 30, in
query_req = pny.select(
^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/pony/orm/core.py", line 5560, in select
return make_query(args, frame_depth=cut_traceback_depth+1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/pony/orm/core.py", line 5546, in make_query
tree, external_names, cells = decompile(gen)
^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/pony/orm/decompiling.py", line 43, in decompile
decompiler = Decompiler(codeobject)
^^^^^^^^^^^^^^^^^^^^^^
File "/app/.venv/lib/python3.12/site-packages/pony/orm/decompiling.py", line 162, in init
decompiler.decompile()
File "/app/.venv/lib/python3.12/site-packages/pony/orm/decompiling.py", line 313, in decompile
throw(DecompileError('Unsupported operation: %s' % opname))
File "/app/.venv/lib/python3.12/site-packages/pony/utils/utils.py", line 99, in throw
raise exc
pony.orm.decompiling.DecompileError: Unsupported operation: POP_JUMP_IF_NOT_NONE

@benmod
Copy link

benmod commented Sep 19, 2024

I am experiencing the same issue, but in my case I get the POP_JUMP_IF_NONE Decompile error.

@j4hangir
Copy link

Same error on Python 3.12:

pony.orm.decompiling.DecompileError: Unsupported operation: POP_JUMP_IF_NONE

Here's the snippet:

select(md for md in MessageData if md.message is self and (md.user is None or md.user == current_user.user))

@cam-mh
Copy link

cam-mh commented Oct 28, 2024

Same error on Python 3.12:

pony.orm.decompiling.DecompileError: Unsupported operation: POP_JUMP_IF_NONE

Here's the snippet:

select(md for md in MessageData if md.message is self and (md.user is None or md.user == current_user.user))

I encountered this issue as well. I was able to solve it by doing:

select(md for md in MessageData if md.message is self and (md.user == None or md.user == current_user.user))

I believe it has something to do with how Python evaluates the abstract syntax tree when constructing the sql statement.

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

4 participants