python / cpython

The Python programming language
https://www.python.org
Other
63.64k stars 30.49k forks source link

mimetypes libmagic compatibility #78521

Open 16bacf18-4d77-42ab-9ae5-3a7757639868 opened 6 years ago

16bacf18-4d77-42ab-9ae5-3a7757639868 commented 6 years ago
BPO 34340

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['extension-modules', 'type-feature'] title = 'mimetypes libmagic compatibility' updated_at = user = 'https://bugs.python.org/bpypy' ``` bugs.python.org fields: ```python activity = actor = 'bpypy' assignee = 'none' closed = False closed_date = None closer = None components = ['Extension Modules'] creation = creator = 'bpypy' dependencies = [] files = [] hgrepos = [] issue_num = 34340 keywords = [] message_count = 1.0 messages = ['323160'] nosy_count = 1.0 nosy_names = ['bpypy'] pr_nums = [] priority = 'normal' resolution = None stage = None status = 'open' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue34340' versions = [] ```

16bacf18-4d77-42ab-9ae5-3a7757639868 commented 6 years ago

An obvious use case for mimetypes would be to check if file has correct mimetype, by getting the type with some of libmagic wrappers, and then comparing to guess_type result.

But it seems that they don't always match. One example: applicattion/rar vs application/x-rar https://github.com/file/file/blob/b9e60f088847f885b5c9fde61ff8fc9645843506/magic/Magdir/archive#L986

Kills half the usefullness of the module.