bpo-30566: Fix IndexError when using punycode codec (GH-18632)
Trying to decode an invalid string with the punycode codec
shoud raise UnicodeError.
(cherry picked from commit ba22e8f174309979d90047c5dc64fcb63bc2c32e)
Co-authored-by: Berker Peksag <berker.peksag@gmail.com>
diff --git a/Lib/encodings/punycode.py b/Lib/encodings/punycode.py
index 66c5101..1c57264 100644
--- a/Lib/encodings/punycode.py
+++ b/Lib/encodings/punycode.py
@@ -143,7 +143,7 @@
digit = char - 22 # 0x30-26
elif errors == "strict":
raise UnicodeError("Invalid extended code point '%s'"
- % extended[extpos])
+ % extended[extpos-1])
else:
return extpos, None
t = T(j, bias)