-
Notifications
You must be signed in to change notification settings - Fork 297
Closed
Description
The Magic class's from_file() 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
_real_open() 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!)
Metadata
Metadata
Assignees
Labels
No labels