code: def _try_repr_or_str(obj: object) -> str:
      try:
          return repr(obj)
      except (KeyboardInterrupt, SystemExit):
          raise
      except BaseException:
          return f'{type(obj).__name__}("{obj}")'
  
file_path: pytest/src/_pytest/_io/saferepr.py
imports: import pprint
  import reprlib
  from typing import Optional
label_desc: Use image node_id 1 for calling a global function with example usage: _try_repr_or_str(obj) and returns: repr, type, str, obj, str