This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Valentin.Lorentz
Recipients Valentin.Lorentz
Date 2017-05-04.16:08:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1493914086.8.0.9964529869.issue30268@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation for mimetypes.guess_type says that it “guesses the type of a file based on its filename or URL”.

However, this function only accepts a string object, and not a bytes object:

>>> import os
>>> import mimetypes
>>> mimetypes.guess_type(os.listdir(os.fsencode('./'))[0])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/mimetypes.py", line 291, in guess_type
    return _db.guess_type(url, strict)
  File "/usr/lib/python3.7/mimetypes.py", line 116, in guess_type
    scheme, url = urllib.parse.splittype(url)
  File "/usr/lib/python3.7/urllib/parse.py", line 924, in splittype
    match = _typeprog.match(url)
TypeError: cannot use a string pattern on a bytes-like object
History
Date User Action Args
2017-05-04 16:08:06Valentin.Lorentzsetrecipients: + Valentin.Lorentz
2017-05-04 16:08:06Valentin.Lorentzsetmessageid: <1493914086.8.0.9964529869.issue30268@psf.upfronthosting.co.za>
2017-05-04 16:08:06Valentin.Lorentzlinkissue30268 messages
2017-05-04 16:08:06Valentin.Lorentzcreate