summaryrefslogtreecommitdiffstats
path: root/Lib/lib2to3
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-04-05 06:37:24 (GMT)
committerGitHub <noreply@github.com>2017-04-05 06:37:24 (GMT)
commit5affd23e6f42125998724787025080a24839266e (patch)
tree8b7ca82362e78a32805b117d574082d512251d3c /Lib/lib2to3
parent43ba8861e0ad044efafa46a7cc04e12ac5df640e (diff)
downloadcpython-5affd23e6f42125998724787025080a24839266e.zip
cpython-5affd23e6f42125998724787025080a24839266e.tar.gz
cpython-5affd23e6f42125998724787025080a24839266e.tar.bz2
bpo-29762: More use "raise from None". (#569)
This hides unwanted implementation details from tracebacks.
Diffstat (limited to 'Lib/lib2to3')
-rw-r--r--Lib/lib2to3/patcomp.py2
-rw-r--r--Lib/lib2to3/pgen2/literals.py4
-rw-r--r--Lib/lib2to3/refactor.py2
3 files changed, 4 insertions, 4 deletions
diff --git a/Lib/lib2to3/patcomp.py b/Lib/lib2to3/patcomp.py
index 06a4b9d..0fefa9a 100644
--- a/Lib/lib2to3/patcomp.py
+++ b/Lib/lib2to3/patcomp.py
@@ -59,7 +59,7 @@ class PatternCompiler(object):
try:
root = self.driver.parse_tokens(tokens, debug=debug)
except parse.ParseError as e:
- raise PatternSyntaxError(str(e))
+ raise PatternSyntaxError(str(e)) from None
if with_tree:
return self.compile_node(root), root
else:
diff --git a/Lib/lib2to3/pgen2/literals.py b/Lib/lib2to3/pgen2/literals.py
index 4f50d31..b9b63e6 100644
--- a/Lib/lib2to3/pgen2/literals.py
+++ b/Lib/lib2to3/pgen2/literals.py
@@ -29,12 +29,12 @@ def escape(m):
try:
i = int(hexes, 16)
except ValueError:
- raise ValueError("invalid hex string escape ('\\%s')" % tail)
+ raise ValueError("invalid hex string escape ('\\%s')" % tail) from None
else:
try:
i = int(tail, 8)
except ValueError:
- raise ValueError("invalid octal string escape ('\\%s')" % tail)
+ raise ValueError("invalid octal string escape ('\\%s')" % tail) from None
return chr(i)
def evalString(s):
diff --git a/Lib/lib2to3/refactor.py b/Lib/lib2to3/refactor.py
index c5a1aa2..70b2a00 100644
--- a/Lib/lib2to3/refactor.py
+++ b/Lib/lib2to3/refactor.py
@@ -248,7 +248,7 @@ class RefactoringTool(object):
try:
fix_class = getattr(mod, class_name)
except AttributeError:
- raise FixerError("Can't find %s.%s" % (fix_name, class_name))
+ raise FixerError("Can't find %s.%s" % (fix_name, class_name)) from None
fixer = fix_class(self.options, self.fixer_log)
if fixer.explicit and self.explicit is not True and \
fix_mod_path not in self.explicit: