Fix https://github.com/ahupp/python-magic/issues/190
Adam Hupp
4 years ago
64 | 64 |
|
65 | 65 |
magic_load(self.cookie, magic_file)
|
66 | 66 |
|
|
67 |
|
|
68 |
# For https://github.com/ahupp/python-magic/issues/190
|
|
69 |
# libmagic has fixed internal limits that some files exceed, causing
|
|
70 |
# an error. We can avoid this (at least for the sample file given)
|
|
71 |
# by bumping the limit up. It's not clear if this is a general solution
|
|
72 |
# or whether other internal limits should be increased, but given
|
|
73 |
# the lack of other reports I'll assume this is rare.
|
|
74 |
self.setparam(MAGIC_PARAM_NAME_MAX, 64)
|
|
75 |
|
67 | 76 |
def from_buffer(self, buf):
|
68 | 77 |
"""
|
69 | 78 |
Identify the contents of `buf`
|
6 | 6 |
THISDIR=`dirname $0`
|
7 | 7 |
export PYTHONPATH=${THISDIR}/..
|
8 | 8 |
|
9 | |
PYTHONS="python2.7 python3.5"
|
|
9 |
PYTHONS="python2.7 python3.5 python3.7"
|
10 | 10 |
|
11 | 11 |
for pyver in $PYTHONS; do
|
12 | 12 |
if which $pyver > /dev/null; then
|
147 | 147 |
m.setparam(magic.MAGIC_PARAM_INDIR_MAX, 1)
|
148 | 148 |
self.assertEqual(m.getparam(magic.MAGIC_PARAM_INDIR_MAX), 1)
|
149 | 149 |
|
|
150 |
def test_name_count(self):
|
|
151 |
m = magic.Magic()
|
|
152 |
with open('testdata/python-3.7.2-python-magic-0.4.15.jpg', 'rb') as f:
|
|
153 |
m.from_buffer(f.read())
|
|
154 |
|
150 | 155 |
if __name__ == '__main__':
|
151 | 156 |
unittest.main()
|