[3.9] bpo-42345: Fix three issues with typing.Literal parameters (GH-23294) (GH-23335)



Literal equality no longer depends on the order of arguments.

Fix issue related to `typing.Literal` caching by adding `typed` parameter to `typing._tp_cache` function.

Add deduplication of `typing.Literal` arguments.

(cherry picked from commit f03d318ca42578e45405717aedd4ac26ea52aaed)

Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
diff --git a/Misc/ACKS b/Misc/ACKS
index 9ad9dff..12a5ac1 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -855,6 +855,7 @@
 Rafe Kaplan
 Jacob Kaplan-Moss
 Allison Kaptur
+Yurii Karabas
 Janne Karila
 Per Øyvind Karlsen
 Anton Kasyanov
diff --git a/Misc/NEWS.d/next/Library/2020-11-15-15-23-34.bpo-42345.hiIR7x.rst b/Misc/NEWS.d/next/Library/2020-11-15-15-23-34.bpo-42345.hiIR7x.rst
new file mode 100644
index 0000000..6339182
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-11-15-15-23-34.bpo-42345.hiIR7x.rst
@@ -0,0 +1,2 @@
+Fix various issues with ``typing.Literal`` parameter handling (flatten,
+deduplicate, use type to cache key). Patch provided by Yurii Karabas.