diff options
| -rw-r--r-- | magic.py | 9 | ||||
| -rwxr-xr-x | test/run.sh | 2 | ||||
| -rwxr-xr-x | test/test.py | 5 | ||||
| -rw-r--r-- | test/testdata/python-3.7.2-python-magic-0.4.15.jpg | bin | 0 -> 1722401 bytes |
4 files changed, 15 insertions, 1 deletions
@@ -65,6 +65,15 @@ class Magic: magic_load(self.cookie, magic_file) + + # For https://github.com/ahupp/python-magic/issues/190 + # libmagic has fixed internal limits that some files exceed, causing + # an error. We can avoid this (at least for the sample file given) + # by bumping the limit up. It's not clear if this is a general solution + # or whether other internal limits should be increased, but given + # the lack of other reports I'll assume this is rare. + self.setparam(MAGIC_PARAM_NAME_MAX, 64) + def from_buffer(self, buf): """ Identify the contents of `buf` diff --git a/test/run.sh b/test/run.sh index 63698ab..ebd7976 100755 --- a/test/run.sh +++ b/test/run.sh @@ -7,7 +7,7 @@ export LC_ALL=en_US.UTF-8 THISDIR=`dirname $0` export PYTHONPATH=${THISDIR}/.. -PYTHONS="python2.7 python3.5" +PYTHONS="python2.7 python3.5 python3.7" for pyver in $PYTHONS; do if which $pyver > /dev/null; then diff --git a/test/test.py b/test/test.py index 0f3aac2..3d835c1 100755 --- a/test/test.py +++ b/test/test.py @@ -148,5 +148,10 @@ class MagicTest(unittest.TestCase): m.setparam(magic.MAGIC_PARAM_INDIR_MAX, 1) self.assertEqual(m.getparam(magic.MAGIC_PARAM_INDIR_MAX), 1) + def test_name_count(self): + m = magic.Magic() + with open('testdata/python-3.7.2-python-magic-0.4.15.jpg', 'rb') as f: + m.from_buffer(f.read()) + if __name__ == '__main__': unittest.main() diff --git a/test/testdata/python-3.7.2-python-magic-0.4.15.jpg b/test/testdata/python-3.7.2-python-magic-0.4.15.jpg Binary files differnew file mode 100644 index 0000000..e2dc2d7 --- /dev/null +++ b/test/testdata/python-3.7.2-python-magic-0.4.15.jpg |
