format_stack.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. from sys import version_info
  2. from warnings import warn
  3. """
  4. Represent an exception with a lot of information.
  5. Provides 2 useful functions:
  6. format_exc: format an exception into a complete traceback, with full
  7. debugging instruction.
  8. format_outer_frames: format the current position in the stack call.
  9. Adapted from IPython's VerboseTB.
  10. This module is deprecated and will be removed in joblib 0.16.
  11. """
  12. from joblib import _deprecated_format_stack
  13. _deprecated_names = [
  14. name for name in dir(_deprecated_format_stack) if
  15. not name.startswith("__") # special attributes
  16. ]
  17. if version_info[:2] >= (3, 7):
  18. def __getattr__(name):
  19. if not name.startswith("__") and name in _deprecated_names:
  20. warn("{} is deprecated and will be removed from joblib "
  21. "in 0.16".format(name), DeprecationWarning)
  22. return getattr(_deprecated_format_stack, name)
  23. raise AttributeError
  24. else:
  25. for name in _deprecated_names:
  26. globals()[name] = getattr(_deprecated_format_stack, name)