Commit b63b5c67 authored by Matthew Edwards's avatar Matthew Edwards Committed by Stefan Behnel

Improve error presentation in IPython magic (GH-3196)

* IPython magic: hide internal traceback when compilation fails
* IPython magic: hide internal traceback when build fails
parent dfc582d2
...@@ -322,6 +322,9 @@ class CythonMagics(Magics): ...@@ -322,6 +322,9 @@ class CythonMagics(Magics):
extension = None extension = None
if need_cythonize: if need_cythonize:
extensions = self._cythonize(module_name, code, lib_dir, args, quiet=args.quiet) 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 assert len(extensions) == 1
extension = extensions[0] extension = extensions[0]
self._code_cache[key] = module_name self._code_cache[key] = module_name
...@@ -329,8 +332,12 @@ class CythonMagics(Magics): ...@@ -329,8 +332,12 @@ class CythonMagics(Magics):
if args.pgo: if args.pgo:
self._profile_pgo_wrapper(extension, lib_dir) self._profile_pgo_wrapper(extension, lib_dir)
self._build_extension(extension, lib_dir, pgo_step_name='use' if args.pgo else None, try:
quiet=args.quiet) 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) module = imp.load_dynamic(module_name, module_path)
self._import_all(module) self._import_all(module)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment