The Magic class's fromfile() method begins with an elegant way of catching certain errors. Lines 110-113 in __init_\.py:
def from_file(self, filename):
# raise FileNotFoundException or IOError if the file does not exist
with _real_open(filename):
pass
_realopen() is just Python's builtin open() function. Lines 28-29 in __init_\.py:
# avoid shadowing the real open with the version from compat.py
_real_open = open
This causes a problem in an admittedly obscure situation: where the target file is a pipe file (mime type "inode/fifo"). The open() function opens the pipe for reading, and then sits there forever waiting for input that never comes. Which means from_file() also just sits there forever, never calling libmagic.magic_file() or returning any value or throwing any error.
(This is my first time reporting an issue on GitHub. Apologies if I've failed to follow the proper procedure!)
Very sorry for the extremely slow response. This was fixed as a happy side effect of 722995466fda1451570c555e688819b75f1b8e65. Your issue report was fine :)
The Magic class's fromfile() method begins with an elegant way of catching certain errors. Lines 110-113 in __init_\.py:
_realopen() is just Python's builtin open() function. Lines 28-29 in __init_\.py:
This causes a problem in an admittedly obscure situation: where the target file is a pipe file (mime type "inode/fifo"). The open() function opens the pipe for reading, and then sits there forever waiting for input that never comes. Which means from_file() also just sits there forever, never calling libmagic.magic_file() or returning any value or throwing any error.
(This is my first time reporting an issue on GitHub. Apologies if I've failed to follow the proper procedure!)