diff -r ad6be34ce8c9 Lib/test/test_urlparse.py --- a/Lib/test/test_urlparse.py Tue Apr 26 01:56:50 2016 +0200 +++ b/Lib/test/test_urlparse.py Tue Apr 26 00:11:24 2016 -0400 @@ -1088,6 +1088,13 @@ url = urllib.parse.unwrap('') self.assertEqual(url, 'type://host/path') + def test_urlparse_deprecation(self): + with self.assertWarns(PendingDeprecationWarning) as dw: + urllib.parse.urlparse('http://www.python.org') + self.assertEqual(str(dw.warning), + 'urlparse with non-str and non-bytes arguments is ' + 'deprecated in Python 3.6') + if __name__ == "__main__": unittest.main() diff -r ad6be34ce8c9 Lib/urllib/parse.py --- a/Lib/urllib/parse.py Tue Apr 26 01:56:50 2016 +0200 +++ b/Lib/urllib/parse.py Tue Apr 26 00:11:24 2016 -0400 @@ -353,6 +353,10 @@ Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" + import warnings + warnings.warn("urlparse with non-str and non-bytes arguments is deprecated " + "in Python 3.6", PendingDeprecationWarning, stacklevel=2) + url, scheme, _coerce_result = _coerce_args(url, scheme) splitresult = urlsplit(url, scheme, allow_fragments) scheme, netloc, url, query, fragment = splitresult