##// END OF EJS Templates
Print message on stderr if annotated html cannot be read.
Bradley M. Froehle -
Show More
@@ -15,6 +15,8 b' Parts of this code were taken from Cython.inline.'
15 # The full license is in the file COPYING.txt, distributed with this software.
15 # The full license is in the file COPYING.txt, distributed with this software.
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17
17
18 from __future__ import print_function
19
18 import io
20 import io
19 import os, sys
21 import os, sys
20 import imp
22 import imp
@@ -194,9 +196,19 b' class CythonMagics(Magics):'
194
196
195 if args.annotate:
197 if args.annotate:
196 html_file = os.path.join(lib_dir, module_name + '.html')
198 html_file = os.path.join(lib_dir, module_name + '.html')
197 with io.open(html_file, encoding='utf-8') as f:
199 try:
198 annotated_html = f.read()
200 with io.open(html_file, encoding='utf-8') as f:
199 return display.HTML(annotated_html)
201 annotated_html = f.read()
202 except IOError as e:
203 # File could not be opened. Most likely the user has a version
204 # of Cython before 0.15.1 (when `cythonize` learned the
205 # `force` keyword argument) and has already compiled this
206 # exact source without annotation.
207 print('Cython completed successfully but the annotated '
208 'source could not be read.', file=sys.stderr)
209 print(e, file=sys.stderr)
210 else:
211 return display.HTML(annotated_html)
200
212
201 _loaded = False
213 _loaded = False
202
214
General Comments 0
You need to be logged in to leave comments. Login now