diff options
| -rw-r--r-- | magic.py | 4 | ||||
| -rwxr-xr-x | test/test.py | 11 |
2 files changed, 14 insertions, 1 deletions
@@ -92,7 +92,9 @@ class Magic: # likely _buffer), but also does not return an error message. if e.message is None and (self.flags & MAGIC_MIME): return "application/octet-stream" - + else: + raise e + def __del__(self): # no _thread_check here because there can be no other # references to this object at this point. diff --git a/test/test.py b/test/test.py index 03914ff..5eaaa0d 100755 --- a/test/test.py +++ b/test/test.py @@ -92,5 +92,16 @@ class MagicTest(unittest.TestCase): m = magic.Magic(mime=True, keep_going=True) self.assertEqual(m.from_file(filename), 'image/jpeg'.encode('utf-8')) + + def test_rethrow(self): + old = magic.magic_buffer + try: + def t(x,y): + raise magic.MagicException("passthrough") + magic.magic_buffer = t + + self.assertRaises(magic.MagicException, magic.from_buffer, "hello", True) + finally: + magic.magic_buffer = old if __name__ == '__main__': unittest.main() |
