608809b
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
608809b
index 77c2007..c6c54b0 100644
608809b
--- a/Lib/test/test_urlparse.py
608809b
+++ b/Lib/test/test_urlparse.py
608809b
@@ -885,6 +885,12 @@ class UrlParseTestCase(unittest.TestCase):
608809b
         self.assertIn('\u2100', denorm_chars)
608809b
         self.assertIn('\uFF03', denorm_chars)
608809b
 
608809b
+        # bpo-36742: Verify port separators are ignored when they
608809b
+        # existed prior to decomposition
608809b
+        urllib.parse.urlsplit('http://\u30d5\u309a:80')
608809b
+        with self.assertRaises(ValueError):
608809b
+            urllib.parse.urlsplit('http://\u30d5\u309a\ufe1380')
608809b
+
608809b
         for scheme in ["http", "https", "ftp"]:
608809b
             for c in denorm_chars:
608809b
                 url = "{}://netloc{}false.netloc/path".format(scheme, c)
608809b
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
608809b
index 243f470..da3a40c 100644
608809b
--- a/Lib/urllib/parse.py
608809b
+++ b/Lib/urllib/parse.py
608809b
@@ -322,13 +322,16 @@ def _checknetloc(netloc):
608809b
     # looking for characters like \u2100 that expand to 'a/c'
608809b
     # IDNA uses NFKC equivalence, so normalize for this check
608809b
     import unicodedata
608809b
-    netloc2 = unicodedata.normalize('NFKC', netloc)
608809b
-    if netloc == netloc2:
608809b
+    n = netloc.rpartition('@')[2] # ignore anything to the left of '@'
608809b
+    n = n.replace(':', '')        # ignore characters already included
608809b
+    n = n.replace('#', '')        # but not the surrounding text
608809b
+    n = n.replace('?', '')
608809b
+    netloc2 = unicodedata.normalize('NFKC', n)
608809b
+    if n == netloc2:
608809b
         return
608809b
-    _, _, netloc = netloc.rpartition('@') # anything to the left of '@' is okay
608809b
     for c in '/?#@:':
608809b
         if c in netloc2:
608809b
-            raise ValueError("netloc '" + netloc2 + "' contains invalid " +
608809b
+            raise ValueError("netloc '" + netloc + "' contains invalid " +
608809b
                              "characters under NFKC normalization")
608809b
 
608809b
 def urlsplit(url, scheme='', allow_fragments=True):