From f50df5120f3584c3375f1a42e413826fe9411a53 Mon Sep 17 00:00:00 2001
From: Kim Davies <kim.davies@iana.org>
Date: Sun, 3 Oct 2021 07:45:11 -0700
Subject: [PATCH] Raise IDNAError on non-ASCII A-Label (fixes #108)

Reference:https://github.com/kjd/idna/commit/f50df5120f3584c3375f1a42e413826fe9411a53
Conflict:NA


---
 src/pip/_vendor/idna/core.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/pip/_vendor/idna/core.py b/src/pip/_vendor/idna/core.py
index d605129..871ebd3 100644
--- a/src/pip/_vendor/idna/core.py
+++ b/src/pip/_vendor/idna/core.py
@@ -383,8 +383,11 @@ def encode(s, strict=False, uts46=False, std3_rules=False, transitional=False):
 
 def decode(s, strict=False, uts46=False, std3_rules=False):
     # type: (Union[str, bytes, bytearray], bool, bool, bool) -> str
-    if isinstance(s, (bytes, bytearray)):
-        s = s.decode('ascii')
+    try:
+        if isinstance(s, (bytes, bytearray)):
+            s = s.decode('ascii')
+    except UnicodeDecodeError:
+        raise IDNAError('Invalid ASCII in A-label')
     if uts46:
         s = uts46_remap(s, std3_rules, False)
     trailing_dot = False

