An open API service indexing awesome lists of open source software.

https://github.com/maxkulish1/patch_js2py

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

error-js2py javascript javascript-to-python keyerror-3 mx-idea patch-js2py python python3 script scripts

Last synced: 10 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# 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:**

```bash
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:

```python
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