New submission from Dong-hee Na <donghee.n...@gmail.com>:
Since urllib.parse.splittype is deprecated on 3.8. In the future urllib.parse._splittype also should be removed. I found that mimetypes.guess_type uses urllib.parse._splittype and it can be replaced and it also looks like solve the issue mentioned on https://github.com/python/cpython/blame/e42b705188271da108de42b55d9344642170aa2b/Lib/test/test_urllib2.py#L749 And I checked that all unit tests are passed when --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -114,7 +114,8 @@ class MimeTypes: but non-standard types. """ url = os.fspath(url) - scheme, url = urllib.parse._splittype(url) + p = urllib.parse.urlparse(url) + scheme, url = p.scheme, p.path if scheme == 'data': # syntax of data URLs: # dataurl := "data:" [ mediatype ] [ ";base64" ] "," data diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 876fcd4199..0677390c2b 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -746,7 +746,7 @@ class HandlerTests(unittest.TestCase): ["foo", "bar"], "", None), ("ftp://localhost/baz.gif;type=a", "localhost", ftplib.FTP_PORT, "", "", "A", - [], "baz.gif", None), # XXX really this should guess image/gif + [], "baz.gif", "image/gif"), ]: req = Request(url) req.timeout = None I'd like to work on this issue if this proposal is accepted! Always thanks ---------- components: Library (Lib) messages: 335061 nosy: corona10 priority: normal severity: normal status: open title: Remove urllib.parse._splittype from mimetypes.guess_type type: enhancement versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35939> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com