code: def _add_to_tbz(tfile, filename, data_str):
      '''
      Adds string data to a tarfile
      '''
  
      # Create a bytesio object for adding to a tarfile
      # https://stackoverflow.com/a/52724508
      encoded_data = data_str.encode('utf-8')
      ti = tarfile.TarInfo(name=filename)
      ti.size = len(encoded_data)
      tfile.addfile(tarinfo=ti, fileobj=io.BytesIO(encoded_data)f _add_to_tbz(tfile, filename, data_str):
      '''
      Adds string data to a tarfile
      '''
  
      # Create a bytesio object for adding to a tarfile
      # https://stackoverflow.com/a/52724508
      encoded_data = data_str.encode('utf-8')
      ti = tarfile.TarInfo(name=filename)
      ti.size = len(encoded_data)
      tfile.addfile(tarinfo=ti, fileobj=io.BytesIO(encoded_data))
docs: Adds string data to a tarfile