Skip to content

Commit

Permalink
Partial fix for #1230: js2py issue under Python 3.8+
Browse files Browse the repository at this point in the history
  • Loading branch information
morpheus65535 committed Jan 18, 2021
1 parent b291746 commit 240a375
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libs/js2py/utils/injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,16 @@ def append_arguments(code_obj, new_locals):
code_obj.co_freevars, code_obj.co_cellvars)

# Done modifying codestring - make the code object
return types.CodeType(*args)
if hasattr(code_obj, "replace"):
# Python 3.8+
return code_obj.replace(
co_argcount=co_argcount + new_locals_len,
co_nlocals=code_obj.co_nlocals + new_locals_len,
co_code=code,
co_names=names,
co_varnames=varnames)
else:
return types.CodeType(*args)


def instructions(code_obj):
Expand Down

0 comments on commit 240a375

Please sign in to comment.