New submission from Cheryl Sabella <[email protected]>:
On a Windows 7 system, entering the following:
>>> mime, encoding = mimetypes.guess_type('Untitled.sql')
>>> mime
'text\\plain'
Meaning, the return value is 'text\\plain' instead of 'text/plain'. Tracking
this down, it's due to .sql being loaded from the Windows registry and the
registry is using the wrong slash.
The mimetypes.guess_type() documentation states:
> The return value is a tuple (type, encoding) where type is None if > the
> type can’t be guessed (missing or unknown suffix) or a string of
> the form 'type/subtype', usable for a MIME content-type header.
I don't know if guess_type() (or add_types) should check for a valid types, if
.sql should be added to the valid types (it's on the IANA page), or if the
documentation should be fixed so it doesn't look like a guarantee. Or all
three. :-)
----------
components: Library (Lib)
messages: 309275
nosy: csabella
priority: normal
severity: normal
status: open
title: mimetypes.guess_type() might be return None or a tuple with
(type/subtype, encoding)
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32462>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com