Description of problem: The python bindings for file (also: python-magic) no longer work with Python 2.7 due to a Python 3 only change Version-Release number of selected component (if applicable): 5.29-3.fc25 How reproducible: Always Steps to Reproduce: 1. open a Python prompt 2. import magic module 3. try to determine the magic of a file Actual results: error Expected results: correct classification of file Additional info: $ python Python 2.7.13 (default, Jan 12 2017, 17:59:37) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import magic >>> ms = magic.open(magic.MAGIC_NONE) >>> ms.file('/tmp/blah') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/magic.py", line 137, in file return str(r, 'utf-8') TypeError: str() takes at most 1 argument (2 given) This error was introduced in upstream file in: https://bugs.gw.com/view.php?id=562 https://github.com/file/file/commit/dc42c23c0575c86b225fd47d2f0a955ea0efc65b
Confirmed. Any idea how to change the code such that it works in both the versions of Python?
I haven't deeply looked into it yet. It seems that in PR511 of upstream it was already noted that the syntax was incompatible: https://bugs.gw.com/view.php?id=511#c1197 but they seemed to have forgotten that a few months later ;-) Maybe the only soluton would be to check the value of sys.version_info[0] ?
Thanks for the tip! I tried it but the current magic.py code fails on your reproducer also with Python 3. So I went for the try/except approach and proposed a patch upstream: https://mx.gw.com/pipermail/file/2017/002270.html
upstream commit: https://github.com/file/file/commit/8a942980
file-5.30-6.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-8e97b5fc2f
file-5.29-4.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2017-5a6a02391d
file-5.29-4.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-5a6a02391d
file-5.30-6.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-8e97b5fc2f
file-5.29-4.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.
file-5.30-6.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.