- l = d._sp.stdout.readline()
- if l != b'!\n': raise RuntimeError("indonor said %s" % repr(l))
- d._sp.stdin.write(expr.encode('utf-8') + b'\n')
- d._sp.stdin.flush()
- l = d._sp.stdout.readline().rstrip(b'\n')
- return int(l)
+ try:
+ l = d._sp.stdout.readline()
+ if l != b'!\n': raise RuntimeError("indonor said %s" % repr(l))
+ d._sp.stdin.write(expr.encode('utf-8') + b'\n')
+ d._sp.stdin.flush()
+ l = d._sp.stdout.readline().rstrip(b'\n')
+ return int(l)
+ except Exception as e:
+ if d._stderr is not None:
+ d._stderr.seek(0)
+ shutil.copyfileobj(d._stderr, sys.stderr)
+ d._stderr.seek(0)
+ d._stderr.truncate()
+ raise e