884
def _failed_to_load_extension(exception):
885
"""Handle failing to load a binary extension.
887
This should be called from the ImportError block guarding the attempt to
888
import the native extension. If this function returns, the pure-Python
889
implementation should be loaded instead::
892
>>> import bzrlib._fictional_extension_pyx
893
>>> except ImportError, e:
894
>>> bzrlib._failed_to_load_extension(e)
895
>>> import bzrlib._fictional_extension_py
897
# NB: This docstring is just an example, not a doctest, because doctest
898
# currently can't cope with the use of lazy imports in this namespace --
901
# we can't use trace.warning, because this can happen early in program
902
# startup before the UIFactory etc is loaded and created; we don't use
903
# Python warnings because they unhelpfully include the line where the
904
# exception was reported, and it's not really a code deprecation warning
907
"bzr: warning: Failed to load compiled extension: "
909
" Bazaar can run, but performance may be reduced.\n"
910
" Check Bazaar is correctly installed.\n"
885
915
from bzrlib._chunks_to_lines_pyx import chunks_to_lines
916
except ImportError, e:
917
_failed_to_load_extension(e)
887
918
from bzrlib._chunks_to_lines_py import chunks_to_lines