ahupp / python-magic

A python wrapper for libmagic
Other
2.6k stars 280 forks source link

MagicException: regex error #276

Closed shurkam closed 1 year ago

shurkam commented 2 years ago

Windows Server 2016, Python 10.0 python-magic 0.4.27 python-magic-bin 0.4.14

Code:

import magic

def main():
    ft = magic.Magic()
    file = 'memblock.h'
    r = ft.from_file(file)
    print(r)

if __name__ == '__main__':
    main()

Exception raised:

Traceback (most recent call last):
  File "c:\win-checkout\dev1.py", line 10, in <module>
    main()
  File "c:\win-checkout\dev1.py", line 6, in main
    r = ft.from_file(file)
  File "c:\Python3\lib\site-packages\magic\magic.py", line 91, in from_file
    return self._handle509Bug(e)
  File "c:\Python3\lib\site-packages\magic\magic.py", line 100, in _handle509Bug
    raise e
  File "c:\Python3\lib\site-packages\magic\magic.py", line 89, in from_file
    return maybe_decode(magic_file(self.cookie, filename))
  File "c:\Python3\lib\site-packages\magic\magic.py", line 255, in magic_file
    return _magic_file(cookie, coerce_filename(filename))
  File "c:\Python3\lib\site-packages\magic\magic.py", line 196, in errorcheck_null
    raise MagicException(err)
magic.magic.MagicException: b"line I64u: regex error 14 for `^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]]*\\{(.*[\n]*)*\\}(;)?$', (failed to get memory)"

The problematic file attached (extension changed to txt). memblock.txt

ahupp commented 1 year ago

Merging into https://github.com/ahupp/python-magic/issues/293