From 5affd23e6f42125998724787025080a24839266e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 5 Apr 2017 09:37:24 +0300 Subject: bpo-29762: More use "raise from None". (#569) This hides unwanted implementation details from tracebacks. --- Lib/warnings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Lib/warnings.py') diff --git a/Lib/warnings.py b/Lib/warnings.py index 5badb0be37..d7d88d3e38 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -209,7 +209,7 @@ def _setoption(arg): if lineno < 0: raise ValueError except (ValueError, OverflowError): - raise _OptionError("invalid lineno %r" % (lineno,)) + raise _OptionError("invalid lineno %r" % (lineno,)) from None else: lineno = 0 filterwarnings(action, message, category, module, lineno) @@ -233,7 +233,7 @@ def _getcategory(category): try: cat = eval(category) except NameError: - raise _OptionError("unknown warning category: %r" % (category,)) + raise _OptionError("unknown warning category: %r" % (category,)) from None else: i = category.rfind(".") module = category[:i] @@ -241,11 +241,11 @@ def _getcategory(category): try: m = __import__(module, None, None, [klass]) except ImportError: - raise _OptionError("invalid module name: %r" % (module,)) + raise _OptionError("invalid module name: %r" % (module,)) from None try: cat = getattr(m, klass) except AttributeError: - raise _OptionError("unknown warning category: %r" % (category,)) + raise _OptionError("unknown warning category: %r" % (category,)) from None if not issubclass(cat, Warning): raise _OptionError("invalid warning category: %r" % (category,)) return cat -- cgit v1.2.1