code: def _print_unix(objects, sep, end, file, flush):
      
  
      encoding = _encoding
  
      if isinstance(sep, text_type):
          sep = sep.encode(encoding, "replace")
      if not isinstance(sep, bytes):
          raise TypeError
  
      if isinstance(end, text_type):
          end = end.encode(encoding, "replace")
      if not isinstance(end, bytes):
          raise TypeError
  
      if end == b"\n":
          end = os.linesep
          if PY3:
              end = end.encode("ascii")
  
      parts = []
      for obj in objects:
          if not isinstance(obj, text_type) and not isinstance(obj, bytes):
              obj = text_type(obj)
          if isinstance(obj, text_type):
              if PY2:
                  obj = obj.encode(encoding, "replace")
              else:
                  try:
                      obj = obj.encode(encoding, "surrogateescape")
                  except UnicodeEncodeError:
                      obj = obj.encode(encoding, "replace")
          assert isinstance(obj, bytes)
          parts.append(obj)
  
      data = sep.join(parts) + end
      assert isinstance(data, bytes)
  
      file = getattr(file, "buffer", file)
  
      try:
          file.write(data)
      except TypeError:
          if PY3:
              # For StringIO, first try with surrogates
              surr_data = data.decode(encoding, "surrogateescape")
              try:
                  file.write(surr_data)
              except (TypeError, ValueError):
                  file.write(data.decode(encoding, "replace"))
          else:
              # for file like objects with don't support bytes
              file.write(data.decode(encoding, "replace"))
  
      if flush:
          file.flush()
docs: A print_() implementation which writes bytes