Python3.6 compatibility
berdario opened this issue · 2 comments
I get the following errors on Python3.6
nose:
Basic test of load_file, check_object_path and load_module ... ERROR
test_basic (test_magic.TestOpcodes)
Basic test of magic numbers ... ERROR
test_basic (test_marsh.TestMarshal)
Tests xdis.load.load_module ... ok
Failure: AssertionError () ... FAIL
======================================================================
ERROR: test_basic (test_load.TestLoad)
Basic test of load_file, check_object_path and load_module
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/nix-build-python3.6-xdis-2.3.1.drv-0/xdis-2.3.1/xdis/load.py", line 95, in load_module
version = float(magics.versions[magic][:3])
KeyError: b'3\r\r\n'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/nix-build-python3.6-xdis-2.3.1.drv-0/xdis-2.3.1/test_unit/test_load.py", line 16, in test_basic
version, timestamp, magic_int, co2, is_pypy = load_module(obj_path)
File "/tmp/nix-build-python3.6-xdis-2.3.1.drv-0/xdis-2.3.1/xdis/load.py", line 100, in load_module
(ord(magic[0])+256*ord(magic[1]), filename))
TypeError: ord() expected string of length 1, but int found
======================================================================
ERROR: test_basic (test_magic.TestOpcodes)
Basic test of magic numbers
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/nix-build-python3.6-xdis-2.3.1.drv-0/xdis-2.3.1/test_unit/test_magic.py", line 10, in test_basic
python_via_magic = magics.by_magic[ current ]
KeyError: b'3\r\r\n'
======================================================================
FAIL: Failure: AssertionError ()
----------------------------------------------------------------------
Traceback (most recent call last):
File "/nix/store/hza739g9wc5ph8zgbab7iqyc711gz3wr-python3.6-nose-1.3.7/lib/python3.6/site-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/nix/store/hza739g9wc5ph8zgbab7iqyc711gz3wr-python3.6-nose-1.3.7/lib/python3.6/site-packages/nose/loader.py", line 417, in loadTestsFromName
addr.filename, addr.module)
File "/nix/store/hza739g9wc5ph8zgbab7iqyc711gz3wr-python3.6-nose-1.3.7/lib/python3.6/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/nix/store/hza739g9wc5ph8zgbab7iqyc711gz3wr-python3.6-nose-1.3.7/lib/python3.6/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/nix/store/jipa3vzflsc4lwhdplc274ps4frz5gqv-python3-3.6.0/lib/python3.6/imp.py", line 234, in load_module
return load_source(name, filename, file)
File "/nix/store/jipa3vzflsc4lwhdplc274ps4frz5gqv-python3-3.6.0/lib/python3.6/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 675, in _load
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/tmp/nix-build-python3.6-xdis-2.3.1.drv-0/xdis-2.3.1/test_unit/test_opcode.py", line 4, in <module>
from xdis.opcodes import (opcode_23, opcode_24, opcode_25,
File "/tmp/nix-build-python3.6-xdis-2.3.1.drv-0/xdis-2.3.1/xdis/opcodes/opcode_36.py", line 94, in <module>
assert all(item in opmap.items() for item in dis.opmap.items())
AssertionError
----------------------------------------------------------------------
Ran 4 tests in 0.072s
FAILED (failures=1, errors=2)
py.test:
============================= test session starts ==============================
platform linux -- Python 3.6.0, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /tmp/nix-build-python3.6-xdis-2.3.1.drv-0/xdis-2.3.1, inifile:
collected 3 items / 2 errors
test_unit/test_load.py .
test_unit/test_magic.py F
test_unit/test_marsh.py .
==================================== ERRORS ====================================
__________________ ERROR collecting test_unit/test_opcode.py ___________________
test_unit/test_opcode.py:4: in <module>
from xdis.opcodes import (opcode_23, opcode_24, opcode_25,
/nix/store/pwmgs44d1pa8p2jw9wbr7v3aw4y1cd2z-python3.6-xdis-2.3.1/lib/python3.6/site-packages/xdis/opcodes/opcode_36.py:94: in <module>
assert all(item in opmap.items() for item in dis.opmap.items())
E assert all(<generator object <genexpr> at 0x7ffff22dd2b0>)
__________________ ERROR collecting test_unit/3.3/test_dis.py __________________
test_unit/3.3/test_dis.py:394: in <module>
class CodeInfoTests(unittest.TestCase):
test_unit/3.3/test_dis.py:396: in CodeInfoTests
(dis.code_info, code_info_code_info),
E NameError: name 'dis' is not defined
=================================== FAILURES ===================================
____________________________ TestOpcodes.test_basic ____________________________
self = <test_magic.TestOpcodes testMethod=test_basic>
def test_basic(self):
"""Basic test of magic numbers"""
current = imp.get_magic()
> python_via_magic = magics.by_magic[ current ]
E KeyError: b'3\r\r\n'
test_unit/test_magic.py:10: KeyError
================= 1 failed, 2 passed, 2 error in 0.16 seconds ==================
I'm not getting an error on my Python 3.6.0 and that magic value b'3\r\r\n'
(as an integer 3379) is definitely there: https://github.com/rocky/python-xdis/blob/master/xdis/magics.py#L111
You definitely are using the wrong code since line 100 of load.py
in your traceback above does not match the current source https://github.com/rocky/python-xdis/blob/master/xdis/load.py#L100
So you make sure you have xdis version 3.2.4 installed which I guess you can figure out via pip freeze xdis
Oh, you're right
The version in use was 2.3.1
(sorry for not spotting it earlier, but I'm updating the version in the package manager, and xdis was only pulled in as a transitive dependency of a test library... I never even heard of xdis before seeing this failure)
Thank you