@@ -668,6 +668,24 @@ def test_attributes_bad_port(self):
668668with self.assertRaises(ValueError):
669669p.port
670670671+def test_attributes_bad_scheme(self):
672+"""Check handling of invalid schemes."""
673+for bytes in (False, True):
674+for parse in (urllib.parse.urlsplit, urllib.parse.urlparse):
675+for scheme in (".", "+", "-", "0", "http&", "६http"):
676+with self.subTest(bytes=bytes, parse=parse, scheme=scheme):
677+url = scheme + "://www.example.net"
678+if bytes:
679+if url.isascii():
680+url = url.encode("ascii")
681+else:
682+continue
683+p = parse(url)
684+if bytes:
685+self.assertEqual(p.scheme, b"")
686+else:
687+self.assertEqual(p.scheme, "")
688+671689def test_attributes_without_netloc(self):
672690# This example is straight from RFC 3261. It looks like it
673691# should allow the username, hostname, and port to be filled