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.
- Host: GitHub
- URL: https://github.com/maxkulish1/patch_js2py
- Owner: MaxKUlish1
- License: mit
- Created: 2024-09-15T08:11:59.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-15T09:14:21.000Z (over 1 year ago)
- Last Synced: 2024-10-18T13:13:59.380Z (over 1 year ago)
- Topics: error-js2py, javascript, javascript-to-python, keyerror-3, mx-idea, patch-js2py, python, python3, script, scripts
- Language: Python
- Homepage: https://t.me/hidden_coding
- Size: 19.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README-en.md
- License: LICENSE
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