diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2018-05-27 14:45:30 +0800 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-05-31 12:56:28 +0800 |
commit | 8374023e3ae0ad4c9ceffb8b5c29aa1fde20433f (patch) | |
tree | 3e1bd54f29edc7b34bc59b2caab0fa46a153f64e /astroid/builder.py | |
parent | 329deed20f8f8d65288ff7ae01b12e69c66f08c7 (diff) | |
download | astroid-git-8374023e3ae0ad4c9ceffb8b5c29aa1fde20433f.tar.gz |
Remove reraise() in favour of using raise..from
Diffstat (limited to 'astroid/builder.py')
-rw-r--r-- | astroid/builder.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/astroid/builder.py b/astroid/builder.py index 320d23a3..968aa410 100644 --- a/astroid/builder.py +++ b/astroid/builder.py @@ -126,18 +126,18 @@ class AstroidBuilder(raw_building.InspectBuilder): try: stream, encoding, data = open_source_file(path) except IOError as exc: - util.reraise(exceptions.AstroidBuildingError( + raise exceptions.AstroidBuildingError( 'Unable to load file {path}:\n{error}', - modname=modname, path=path, error=exc)) + modname=modname, path=path) from exc except (SyntaxError, LookupError) as exc: - util.reraise(exceptions.AstroidSyntaxError( + raise exceptions.AstroidSyntaxError( 'Python 3 encoding specification error or unknown encoding:\n' - '{error}', modname=modname, path=path, error=exc)) - except UnicodeError: # wrong encoding + '{error}', modname=modname, path=path) from exc + except UnicodeError as exc: # wrong encoding # detect_encoding returns utf-8 if no encoding specified - util.reraise(exceptions.AstroidBuildingError( + raise exceptions.AstroidBuildingError( 'Wrong or no encoding specified for {filename}.', - filename=path)) + filename=path) from exc with stream: # get module name if necessary if modname is None: @@ -179,9 +179,9 @@ class AstroidBuilder(raw_building.InspectBuilder): try: node = _parse(data + '\n') except (TypeError, ValueError, SyntaxError) as exc: - util.reraise(exceptions.AstroidSyntaxError( + raise exceptions.AstroidSyntaxError( 'Parsing Python code failed:\n{error}', - source=data, modname=modname, path=path, error=exc)) + source=data, modname=modname, path=path) from exc if path is not None: node_file = os.path.abspath(path) else: |