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

KeyError in python3.12.0 #317

Open
LeadroyaL opened this issue Oct 13, 2023 · 5 comments · May be fixed by #327
Open

KeyError in python3.12.0 #317

LeadroyaL opened this issue Oct 13, 2023 · 5 comments · May be fixed by #327

Comments

@LeadroyaL
Copy link

# python --version
Python 3.12.0

# pipdeptree
Js2Py==0.74
├── pyjsparser [required: >=2.5.1, installed: 2.7.1]
├── six [required: >=1.10, installed: 1.16.0]
└── tzlocal [required: >=1.2, installed: 5.1]
    └── tzdata [required: Any, installed: 2023.3]

# cat .\test.py
import js2py
Traceback (most recent call last):
  File "D:\PycharmProjects\test.py", line 1, in <module>
    import js2py
  File "D:\Python\Python312\Lib\site-packages\js2py\__init__.py", line 72, in <module>
    from .base import PyJsException
  File "D:\Python\Python312\Lib\site-packages\js2py\base.py", line 2965, in <module>
    @Js
     ^^
  File "D:\Python\Python312\Lib\site-packages\js2py\base.py", line 165, in Js
    return PyJsFunction(val, FunctionPrototype)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\Python312\Lib\site-packages\js2py\base.py", line 1377, in __init__
    cand = fix_js_args(func)
           ^^^^^^^^^^^^^^^^^
  File "D:\Python\Python312\Lib\site-packages\js2py\utils\injector.py", line 27, in fix_js_args
    code = append_arguments(six.get_function_code(func), ('this', 'arguments'))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python\Python312\Lib\site-packages\js2py\utils\injector.py", line 121, in append_arguments
    arg = name_translations[inst.arg]
          ~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 3

Process finished with exit code 1
@worstperson
Copy link
Collaborator

Assuming this was a very simple test since no code was shared. Might have to do with changes made in 3.12, idk, 3.11 initially broke support too. I'll force an update through AUR and see if I can reproduce over the weekend.

@miigotu
Copy link

miigotu commented Oct 24, 2023

Assuming this was a very simple test since no code was shared. Might have to do with changes made in 3.12, idk, 3.11 initially broke support too. I'll force an update through AUR and see if I can reproduce over the weekend.

code is there

python3.12 -c "import js2py"

@worstperson
Copy link
Collaborator

Sorry, I didn't have a solution so I avoided replying. It's crashing because of a change in the bytecode described here
https://docs.python.org/3/library/dis.html#opcode-LOAD_ATTR
corresponding to this line of the disassembly
14 LOAD_ATTR 3 (NULL|self + is_undefined)
In previous versions it was
16 LOAD_METHOD 1 (is_undefined)

It looks like the code that generates the 'names' table needs to be updated to include these new expressions, but I don't fully understand the code, so more testing and research needs to be done before I can suggest a patch and I haven't really found the time for it.

@RiteshEdugorilla
Copy link

Have any solution for this issue.

@felixonmars
Copy link

Please try #327 which at least passes simple_test for me :)

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

Successfully merging a pull request may close this issue.

5 participants