Skip to content

Commit

Permalink
Add IS_PYPY3 to DRY code
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Apr 30, 2019
1 parent af82fdf commit f04b282
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Binary file modified test/bytecode_pypy3.6/00_assign.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions xdis/load.py
Expand Up @@ -50,7 +50,7 @@ def check_object_path(path):
return path

def is_pypy(magic_int):
return magic_int in (62211+7, 3180+7, 48, 112, 160)
return magic_int in (62211+7, 3180+7, *magics.IS_PYPY3)

def load_file(filename, out=sys.stdout):
"""
Expand Down Expand Up @@ -180,7 +180,7 @@ def load_module_from_file_object(fp, filename='<unknown>', code_objects=None, fa
# PYTHON_VERSION, although PYTHON_VERSION would probably work.
if ( ( (3200 <= magic_int < 20121) and
(magic_int not in (5892, 11913, 39170, 39171)) )
or (magic_int in (48, 112, 160)) ):
or (magic_int in magics.IS_PYPY3) ):

source_size = unpack("<I", fp.read(4))[0] # size mod 2**32
else:
Expand Down
2 changes: 2 additions & 0 deletions xdis/magics.py
Expand Up @@ -35,6 +35,8 @@
import imp, re, struct, sys
from xdis import IS_PYPY

IS_PYPY3 = (48, 112, 160)

def add_magic_from_int(magic_int, version):
magicint2version[magic_int] = version
versions[int2magic(magic_int)] = version
Expand Down

0 comments on commit f04b282

Please sign in to comment.