diff options
author | Matthew Edwards <mje-nz@users.noreply.github.com> | 2019-10-22 07:01:46 +1300 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2019-10-21 20:01:46 +0200 |
commit | a32a29e8aaa688e0507d374ab47e641eb1a427c4 (patch) | |
tree | 226353cf2d3958fbdf97f8a403c15d83b4c09aee | |
parent | 05059e2a9b89bf6738a7750b905057e5b1e3fe2e (diff) | |
download | cython-a32a29e8aaa688e0507d374ab47e641eb1a427c4.tar.gz |
Improve error presentation in IPython magic (GH-3196)
* IPython magic: hide internal traceback when compilation fails
* IPython magic: hide internal traceback when build fails
-rw-r--r-- | Cython/Build/IpythonMagic.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Cython/Build/IpythonMagic.py b/Cython/Build/IpythonMagic.py index 0f49a7e8c..193214544 100644 --- a/Cython/Build/IpythonMagic.py +++ b/Cython/Build/IpythonMagic.py @@ -323,6 +323,9 @@ class CythonMagics(Magics): extension = None if need_cythonize: extensions = self._cythonize(module_name, code, lib_dir, args, quiet=args.quiet) + if extensions is None: + # Compilation failed and printed error message + return None assert len(extensions) == 1 extension = extensions[0] self._code_cache[key] = module_name @@ -330,8 +333,12 @@ class CythonMagics(Magics): if args.pgo: self._profile_pgo_wrapper(extension, lib_dir) - self._build_extension(extension, lib_dir, pgo_step_name='use' if args.pgo else None, - quiet=args.quiet) + try: + self._build_extension(extension, lib_dir, pgo_step_name='use' if args.pgo else None, + quiet=args.quiet) + except distutils.errors.CompileError: + # Build failed and printed error message + return None module = imp.load_dynamic(module_name, module_path) self._import_all(module) |