diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-04-05 06:37:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-05 06:37:24 (GMT) |
commit | 5affd23e6f42125998724787025080a24839266e (patch) | |
tree | 8b7ca82362e78a32805b117d574082d512251d3c /Lib/warnings.py | |
parent | 43ba8861e0ad044efafa46a7cc04e12ac5df640e (diff) | |
download | cpython-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/warnings.py')
-rw-r--r-- | Lib/warnings.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/warnings.py b/Lib/warnings.py index 5badb0b..d7d88d3 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 |