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

assert instr.opname.startswith("CALL_") throws on Python 3.11 #49

Closed
lemenkov opened this issue May 27, 2023 · 5 comments
Closed

assert instr.opname.startswith("CALL_") throws on Python 3.11 #49

lemenkov opened this issue May 27, 2023 · 5 comments

Comments

@lemenkov
Copy link

lemenkov commented May 27, 2023

Hello!
Similar to this StackOverflow message I've got the same error while trying to (indirectly) use docopt-ng with Python 3.11.

I've added print(instr.opname) right after the line 941 and the resulting list of instructions indeed doesn't have anything stareted with CALL_ (see file atached). On the contrary here is a move shorter list of instructions when I run the same with Python 3.10:

LOAD_GLOBAL
LOAD_GLOBAL
LOAD_CONST
LOAD_CONST
CALL_FUNCTION_KW

If I remove the following block completely along with output_value_assigned variable then everything seems to work just fine with Python 3.11:

if more_magic and parent_frame:
import dis
instrs = dis.get_instructions(parent_frame.f_code)
for instr in instrs:
if instr.offset == parent_frame.f_lasti:
break
assert instr.opname.startswith("CALL_")
MAYBE_STORE = next(instrs)
if MAYBE_STORE and (
MAYBE_STORE.opname.startswith("STORE")
or MAYBE_STORE.opname.startswith("RETURN")
):
output_value_assigned = True

@NickCrews
Copy link
Contributor

Thanks for the report!

It was inevitable that something would break with how we are reaching into internals like this. The whole "magic" thing was a mistake of a feature I think, oh well.

I'll take a look and try to come up with some workaround.

@lemenkov
Copy link
Author

So, apparently CALL_FUNCTION, CALL_FUNCTION_KW, CALL_METHOD, CALL_METHOD_KW were removed from Python 3.11. See python/cpython#88691 for the details.

@lemenkov
Copy link
Author

Thanks for the report!

It was inevitable that something would break with how we are reaching into internals like this. The whole "magic" thing was a mistake of a feature I think, oh well.

I'll take a look and try to come up with some workaround.

Thanks! Looking forward to it!

@lemenkov lemenkov reopened this May 30, 2023
@NickCrews
Copy link
Contributor

OK, so brownie is using a vendored version of docopt, so if I fix the bug here then you won't see that change unless they pull that in. I still will look for the bug and probably fix it, but FYI you are going to have to go through more steps.

NickCrews added a commit that referenced this issue May 30, 2023
1. lockfiles, so CI can be consistent. It wasn't locked and was failing
because of this.
2. less boiler plate for building and
uploading wheels, for setting up dev env
3. allows venvs for different python verisons, useful for
eg #49
4. less config files
5. add metadata to pyproject.toml, for better ecosystem interoperability
6. Just more modern and better updates.
NickCrews added a commit that referenced this issue May 30, 2023
1. lockfiles, so CI can be consistent. It wasn't locked and was failing
because of this.
2. less boiler plate for building and
uploading wheels, for setting up dev env
3. allows venvs for different python verisons, useful for
eg #49
4. less config files
5. add metadata to pyproject.toml, for better ecosystem interoperability
6. Just more modern and better updates.
@NickCrews
Copy link
Contributor

OK this is fixed in #51 (by just deleting the problematic feature ;) ). You will now need to get brownie to re-pull this updated version (or perhaps depend on it from PyPI, I'm not sure why they have it vendored, but they are going to keep getting this problem otherwise)

I'll leave this open for now if you have any problems, but will close soon.

lemenkov added a commit to lemenkov/brownie that referenced this issue Jun 2, 2023
Upgrade docopt to ver. 0.9.0 to restore compatibility with Python 3.11.
See jazzband/docopt-ng#49 for further details.

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
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

2 participants