* [gentoo-commits] repo/gentoo:master commit in: dev-python/js2py/files/, dev-python/js2py/
@ 2024-06-25 0:26 Maciej Barć
0 siblings, 0 replies; only message in thread
From: Maciej Barć @ 2024-06-25 0:26 UTC (permalink / raw
To: gentoo-commits
commit: ae7e3902e84e912b3450f206307faa7b32a9961a
Author: Maciej Barć <xgqt <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 25 00:16:43 2024 +0000
Commit: Maciej Barć <xgqt <AT> gentoo <DOT> org>
CommitDate: Tue Jun 25 00:26:14 2024 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ae7e3902
dev-python/js2py: patch for py3.12
Signed-off-by: Maciej Barć <xgqt <AT> gentoo.org>
.../js2py/files/js2py-0.74-py312-load_attr.patch | 57 ++++++++++++++++++++++
.../{js2py-0.74-r1.ebuild => js2py-0.74-r2.ebuild} | 3 +-
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/dev-python/js2py/files/js2py-0.74-py312-load_attr.patch b/dev-python/js2py/files/js2py-0.74-py312-load_attr.patch
new file mode 100644
index 000000000000..6dfa467cc41f
--- /dev/null
+++ b/dev-python/js2py/files/js2py-0.74-py312-load_attr.patch
@@ -0,0 +1,57 @@
+From fd7df4a91fb08060914c7b1d9e94583d18f3371b Mon Sep 17 00:00:00 2001
+From: Felix Yan <felixonmars@archlinux.org>
+Date: Wed, 17 Apr 2024 16:47:47 +0300
+Subject: [PATCH] Fix bytecode for Python 3.12
+
+`LOAD_ATTR` has been changed in Python 3.12 and it seems reusing the
+`LOAD_GLOBAL` logic makes the simple tests passing.
+
+I am not sure if this is correct since I'm pretty new to the code, but
+maybe it's still helpful.
+---
+ js2py/translators/translating_nodes.py | 2 +-
+ js2py/utils/injector.py | 4 +++-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/js2py/translators/translating_nodes.py b/js2py/translators/translating_nodes.py
+index 4e2b5760..a780ba73 100644
+--- a/js2py/translators/translating_nodes.py
++++ b/js2py/translators/translating_nodes.py
+@@ -543,7 +543,7 @@ def TryStatement(type, block, handler, handlers, guardedHandlers, finalizer):
+ if handler:
+ identifier = handler['param']['name']
+ holder = 'PyJsHolder_%s_%d' % (to_hex(identifier),
+- random.randrange(1e8))
++ random.randrange(six.integer_types[-1](1e8)))
+ identifier = repr(identifier)
+ result += 'except PyJsException as PyJsTempException:\n'
+ # fill in except ( catch ) block and remember to recover holder variable to its previous state
+diff --git a/js2py/utils/injector.py b/js2py/utils/injector.py
+index 88e0d93e..835229f0 100644
+--- a/js2py/utils/injector.py
++++ b/js2py/utils/injector.py
+@@ -14,6 +14,7 @@
+ # Opcode constants used for comparison and replacecment
+ LOAD_FAST = opcode.opmap['LOAD_FAST']
+ LOAD_GLOBAL = opcode.opmap['LOAD_GLOBAL']
++LOAD_ATTR = opcode.opmap['LOAD_ATTR']
+ STORE_FAST = opcode.opmap['STORE_FAST']
+
+
+@@ -79,6 +80,7 @@ def append_arguments(code_obj, new_locals):
+ (co_names.index(name), varnames.index(name)) for name in new_locals)
+
+ is_new_bytecode = sys.version_info >= (3, 11)
++ is_new_load_attr = sys.version_info >= (3, 12)
+ # Now we modify the actual bytecode
+ modified = []
+ drop_future_cache = False
+@@ -97,7 +99,7 @@ def append_arguments(code_obj, new_locals):
+ # it's one of the globals that we are replacing. Either way,
+ # update its arg using the appropriate dict.
+ drop_future_cache = False
+- if inst.opcode == LOAD_GLOBAL:
++ if inst.opcode == LOAD_GLOBAL or (is_new_load_attr and inst.opcode == LOAD_ATTR):
+ idx = inst.arg
+ if is_new_bytecode:
+ idx = idx // 2
diff --git a/dev-python/js2py/js2py-0.74-r1.ebuild b/dev-python/js2py/js2py-0.74-r2.ebuild
similarity index 91%
rename from dev-python/js2py/js2py-0.74-r1.ebuild
rename to dev-python/js2py/js2py-0.74-r2.ebuild
index 800b93584b27..025770effe38 100644
--- a/dev-python/js2py/js2py-0.74-r1.ebuild
+++ b/dev-python/js2py/js2py-0.74-r2.ebuild
@@ -27,7 +27,8 @@ RDEPEND="
"
PATCHES=(
- "${FILESDIR}"/${P}-CVE-2024-28397.patch
+ "${FILESDIR}/${PN}-0.74-CVE-2024-28397.patch"
+ "${FILESDIR}/${PN}-0.74-py312-load_attr.patch"
)
python_test() {
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-06-25 0:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-25 0:26 [gentoo-commits] repo/gentoo:master commit in: dev-python/js2py/files/, dev-python/js2py/ Maciej Barć
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox