from io import StringIO


def ihex_to_str(ih):
    """Convert an Intel Hex instance into an Intel Hex string."""
    sio = StringIO()
    ih.write_hex_file(sio)
    hex_str = sio.getvalue()
    sio.close()
    return hex_str