ahupp / python-magic

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

fix: Don't raise FileNotFoundException on symlinks #292

Closed maringuu closed 1 year ago

maringuu commented 1 year ago

The builtin open will always follow symlinks. Using os.stat is the easiest solution imo. An alternative would be using os.access but that does not raise a FileNotFoundException so I chose os.stat.

As a sidenote I'd like to mention that setting MAGIC_SYMLINK is not possible, is it?

ahupp commented 1 year ago

lgtm, thanks!

ahupp commented 1 year ago

I've added support for MAGIC_SYMLINK, and test for that and this change in 2a01b18ae0fe27e51977a54f0589910ddcc05804

maringuu commented 1 year ago

I've added support for MAGIC_SYMLINK, and test for that and this change in 2a01b18

Great, thank you!