Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 455869a

Browse files
authored
Revert "[3.7] bpo-22347: Update mimetypes.guess_type to allow proper parsing of URLs (GH-15522) (GH-15687)"
This reverts commit 8873bff.
1 parent 193366e commit 455869a

File tree

3 files changed

+2
-11
lines changed

3 files changed

+2
-11
lines changed

Lib/mimetypes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ def guess_type(self, url, strict=True):
114114
but non-standard types.
115115
"""
116116
url = os.fspath(url)
117-
p = urllib.parse.urlparse(url)
118-
scheme, url = p.scheme, p.path
117+
scheme, url = urllib.parse.splittype(url)
119118
if scheme == 'data':
120119
# syntax of data URLs:
121120
# dataurl := "data:" [ mediatype ] [ ";base64" ] "," data

Lib/test/test_mimetypes.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ def test_non_standard_types(self):
5050
eq(self.db.guess_type('foo.xul', strict=False), ('text/xul', None))
5151
eq(self.db.guess_extension('image/jpg', strict=False), '.jpg')
5252

53-
def test_url(self):
54-
result = self.db.guess_type('http://host.html')
55-
msg = 'URL only has a host name, not a file'
56-
self.assertSequenceEqual(result, (None, None), msg)
57-
result = self.db.guess_type('http://example.com/host.html')
58-
msg = 'Should be text/html'
59-
self.assertSequenceEqual(result, ('text/html', None), msg)
60-
6153
def test_guess_all_types(self):
6254
eq = self.assertEqual
6355
unless = self.assertTrue

Lib/test/test_urllib2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ def connect_ftp(self, user, passwd, host, port, dirs,
746746
["foo", "bar"], "", None),
747747
("ftp://localhost/baz.gif;type=a",
748748
"localhost", ftplib.FTP_PORT, "", "", "A",
749-
[], "baz.gif", "image/gif"),
749+
[], "baz.gif", None), # XXX really this should guess image/gif
750750
]:
751751
req = Request(url)
752752
req.timeout = None

0 commit comments

Comments
 (0)