Js2Py
Js2Py copied to clipboard
KeyError in python3.12.0
# 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
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.
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"
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.
Have any solution for this issue.
Please try https://github.com/PiotrDabkowski/Js2Py/pull/327 which at least passes simple_test for me :)