diff --git a/src/sage/misc/cython.py b/src/sage/misc/cython.py index 9111f25c72b..9e14c603b02 100644 --- a/src/sage/misc/cython.py +++ b/src/sage/misc/cython.py @@ -88,7 +88,7 @@ def _webbrowser_open_file(path): def cython(filename, verbose=0, compile_message=False, use_cache=False, create_local_c_file=False, annotate=True, view_annotate=False, - view_annotate_callback=_webbrowser_open_file, sage_namespace=True, create_local_so_file=False): + view_annotate_callback=None, sage_namespace=True, create_local_so_file=False): r""" Compile a Cython file. This converts a Cython file to a C (or C++ file), and then compiles that. The .c file and the .so file are @@ -124,7 +124,8 @@ def cython(filename, verbose=0, compile_message=False, - ``view_annotate_callback`` -- function; a function that takes a string being the path to the html file. This can be overridden to change what to do with the annotated html file. Have no effect unless - ``view_annotate`` is ``True``. + ``view_annotate`` is ``True``. By default, the html file is opened in a + web browser. - ``sage_namespace`` -- boolean (default: ``True``); if ``True``, import ``sage.all`` @@ -271,6 +272,9 @@ def cython(filename, verbose=0, compile_message=False, sage: len(collected_paths) 1 """ + if view_annotate_callback is None: + # needed because of https://github.com/sagemath/sage/pull/38946#issuecomment-2656329774 + view_annotate_callback = _webbrowser_open_file if not filename.endswith('pyx'): print("Warning: file (={}) should have extension .pyx".format(filename), file=sys.stderr)