code: def safe_str(value):
      
      if sys.version_info < (3,0) and isinstance(value, unicode):
          return value.encode('utf-8')
      else:
          return str(value)
docs: Returns:
  
      * a `str` instance (bytes) in Python 2.x, or
      * a `str` instance (Unicode) in Python 3.x.