Skip to content

MaxKUlish1/patch_js2py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RU

js2py Compatibility Fix

Overview

This repository provides a patch for the js2py library to ensure compatibility with Python versions 3.12 and above. The js2py library, a popular JavaScript-to-Python transpiler, has compatibility issues with newer Python versions due to changes in bytecode and opcode mappings. This patch addresses these issues to restore functionality.

Installation

  1. Apply the compatibility patch: Run the provided Python script to modify the necessary files in the js2py package:

    python apply_patch.py

Files Modified

  • js2py/translators/translating_nodes.py: Updates the random number generation for compatibility.
  • js2py/utils/injector.py: Adds LOAD_ATTR opcode mapping and adjusts bytecode handling for newer Python versions.

Example

To demonstrate the use of this patched js2py library, here is a basic example:

from js2py import eval_js

js_code = 'function add(a, b) { return a + b; }'
js_function = eval_js(js_code)
result = js_function(5, 3)
print(result)  # Output should be 8

About

js2py не работает корректно с версиями Python 3.12 и выше из-за изменений во внутреннем представлении байт-кода и сопоставлении опкодов в Python. Этот репозиторий предлагает решение, модифицируя соответствующие файлы в пакете js2py, чтобы поддерживать новые версии Python.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages