Skip to content

Commit 32b3e51

Browse files
author
rocky
committed
Note Jython 65226 (2.7.4 Jython)
1 parent c3fd600 commit 32b3e51

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

xdis/codetype/code20.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@
3030
"co_cellvars": (tuple, list),
3131
}
3232
)
33-
# co_firstlineno added since 1.x
3433

35-
# Early pyston 2.7 Code objects seem to be a subset of 2.0 code.
36-
# The fields it has are:
37-
# co_argcount, co_filename, co_firstline, co_flag, co_name, co_varnames
34+
# Byte code that is JVM, e.g. Pyston and Jython do provide a subset
35+
# of Pythons code fields.
36+
# For pyston, the fields it has are:
37+
# co_argcount, co_filename, co_firstline, co_flags, co_name, co_varnames
38+
#
39+
# For Jython the fields it has are:
40+
# co_argcount, co_cellvars, co_filename, co_firstline, co_flags, co_freevars,
41+
# co_name, co_nlocals, co_varnames
42+
#
3843

3944
class Code2(Code15):
4045
"""Class for a Python2 code object used when a Python 3 interpreter is

xdis/load.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def load_module_from_file_object(
230230
else:
231231
raise ImportError(f"Bad magic number: '{magic}'")
232232

233-
if magic_int in (2657, 22138):
233+
if magic_int in (2657, 65226, 22138):
234234
version = magicint2version.get(magic_int, "")
235235
raise ImportError(f"Magic int {magic_int} ({version}) is not supported.")
236236

xdis/magics.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,19 @@ def __by_version(magic_versions: Dict[bytes, str]) -> dict:
465465
add_magic_from_int(12897, "3.12.0rust") # RustPython 3.12.0
466466
add_magic_from_int(12641, "3.13.0rust") # RustPython 3.13.0
467467

468-
# NOTE: This is JVM bytecode not Python bytecode
468+
# Graal uses JVM bytecode, not Python bytecode
469469
add_magic_from_int(21150, "3.8.5Graal")
470470

471471
# Graal Java 21.0.2
472472
add_magic_from_int(21280, "3.10.8Graal")
473473
add_magic_from_int(21290, "3.11.7Graal")
474474

475475

476-
add_magic_from_int(1011, "2.7.1b3Jython") # jython
476+
# Jython uses JVM bytecode, not Python bytecode.
477+
add_magic_from_int(1011, "2.7.1b3Jython") # Jython 2.7.2b3
478+
add_magic_from_int(65226, "2.7.4Jython") # Jython 2.7.4
479+
480+
# Pyston
477481
add_magic_from_int(22138, "2.7.7Pyston") # 2.7.8pyston, pyston-0.6.0
478482

479483
magics = __by_version(versions)

0 commit comments

Comments
 (0)