Backport r59480.
Fix issue #1313119.
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
index eade040..ad5d75f 100644
--- a/Lib/urlparse.py
+++ b/Lib/urlparse.py
@@ -184,7 +184,7 @@
     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."""
     allow_fragments = bool(allow_fragments)
-    key = url, scheme, allow_fragments
+    key = url, scheme, allow_fragments, type(url), type(scheme)
     cached = _parse_cache.get(key, None)
     if cached:
         return cached