bpo-44633: Fix parameter substitution of the union type with wrong types. (GH-27218) (GH-27224)

A TypeError is now raised instead of returning NotImplemented.
(cherry picked from commit 3ea5332a4365bdd771286b3e9692495116e9ceef)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
3 files changed