code: def warn_with_traceback(message, category, filename, lineno, file=None, line=None):
      
      import traceback
      traceback.print_stack()
      log = file if hasattr(file, 'write') else sys.stderr
      settings.write(warnings.formatwarning(message, category, filename, lineno, line))
docs: Get full tracebacks when warning is raised by setting
  
      warnings.showwarning = warn_with_traceback
  
      See also
      --------
      http://stackoverflow.com/questions/22373927/get-traceback-of-warnings