Skip to content

Commit 9e6bafb

Browse files
committed
Fix cpp2py Ipython magic to print proper compilation error messages
1 parent 8a96071 commit 9e6bafb

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

cpp2py/compiler.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44
cxx_compiler = Config.CXX_COMPILER
55

66
def print_out (m, out) :
7-
l = (70 - len(m))/2
7+
l = (70 - len(m))//2
88
print(l*'-' + m + l*'-' + '\n' + out)
99

1010
def execute(command, message):
11-
#print("EXEC", command)
1211
try:
1312
out = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
14-
except subprocess.CalledProcessError as E :
15-
print_out (message + " error ", E.output)
13+
except subprocess.CalledProcessError as E:
14+
print_out (message + " error ", E.output.decode('utf8'))
1615
raise RuntimeError("Error")
17-
#if verbosity>0:
18-
#print_out(message, out)
19-
#print(message)
2016

2117
def compile(code, verbosity =0, only=(), modules = '', cxxflags= '', moduledir = '/tmp', recompile = False, no_clean = False):
2218
"""
@@ -90,6 +86,7 @@ def compile(code, verbosity =0, only=(), modules = '', cxxflags= '', moduledir =
9086
except: # we clean if fail
9187
os.chdir(old_cwd)
9288
if not no_clean : shutil.rmtree(module_dirname)
89+
raise
9390

9491
finally:
9592
os.chdir(old_cwd)

0 commit comments

Comments
 (0)