bpo-29762: More use "raise from None". (#569)
This hides unwanted implementation details from tracebacks.
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py
index 2422c6a..3741dee 100644
--- a/Lib/json/decoder.py
+++ b/Lib/json/decoder.py
@@ -103,7 +103,8 @@
try:
esc = s[end]
except IndexError:
- raise JSONDecodeError("Unterminated string starting at", s, begin)
+ raise JSONDecodeError("Unterminated string starting at",
+ s, begin) from None
# If not a unicode escape sequence, must be in the lookup table
if esc != 'u':
try:
diff --git a/Lib/json/scanner.py b/Lib/json/scanner.py
index 86426cd..c451eba 100644
--- a/Lib/json/scanner.py
+++ b/Lib/json/scanner.py
@@ -29,7 +29,7 @@
try:
nextchar = string[idx]
except IndexError:
- raise StopIteration(idx)
+ raise StopIteration(idx) from None
if nextchar == '"':
return parse_string(string, idx + 1, strict)