|
5 | 5 |
|
6 | 6 | from future import standard_library |
7 | 7 | standard_library.install_aliases() |
8 | | -from future.utils import raise_from |
9 | 8 | from builtins import next |
10 | 9 | from pickle import dumps, loads |
11 | 10 | import inspect |
@@ -91,14 +90,14 @@ def create_function_from_source(function_source, imports=None): |
91 | 90 | import_keys = list(ns.keys()) |
92 | 91 | exec(function_source, ns) |
93 | 92 |
|
94 | | - except Exception as e: |
95 | | - msg = '\nError executing function:\n %s\n' % function_source |
| 93 | + except Exception as msg: |
| 94 | + msg = str(msg) + '\nError executing function:\n %s\n' % function_source |
96 | 95 | msg += '\n'.join(["Functions in connection strings have to be standalone.", |
97 | 96 | "They cannot be declared either interactively or inside", |
98 | 97 | "another function or inline in the connect string. Any", |
99 | 98 | "imports should be done inside the function" |
100 | 99 | ]) |
101 | | - raise_from(RuntimeError(msg), e) |
| 100 | + raise RuntimeError(msg) |
102 | 101 | ns_funcs = list(set(ns) - set(import_keys + ['__builtins__'])) |
103 | 102 | assert len(ns_funcs) == 1, "Function or inputs are ill-defined" |
104 | 103 | funcname = ns_funcs[0] |
@@ -200,14 +199,14 @@ def package_check(pkg_name, version=None, app=None, checker=LooseVersion, |
200 | 199 | msg += ' with version >= %s' % (version,) |
201 | 200 | try: |
202 | 201 | mod = __import__(pkg_name) |
203 | | - except ImportError as e: |
204 | | - raise_from(exc_failed_import(msg), e) |
| 202 | + except ImportError: |
| 203 | + raise exc_failed_import(msg) |
205 | 204 | if not version: |
206 | 205 | return |
207 | 206 | try: |
208 | 207 | have_version = mod.__version__ |
209 | | - except AttributeError as e: |
210 | | - raise_from(exc_failed_check('Cannot find version for %s' % pkg_name), e) |
| 208 | + except AttributeError: |
| 209 | + raise exc_failed_check('Cannot find version for %s' % pkg_name) |
211 | 210 | if checker(have_version) < checker(version): |
212 | 211 | raise exc_failed_check(msg) |
213 | 212 |
|
|
0 commit comments