Skip to content

Commit

Permalink
Merge branch 'fix/runtool_crcrlf_v5.1' into 'release/v5.1'
Browse files Browse the repository at this point in the history
fix: save RunTool command output with correct line endings (v5.1)

See merge request espressif/esp-idf!28678
  • Loading branch information
dobairoland committed Feb 27, 2024
2 parents b552d06 + f3c6aa9 commit f85280f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/idf_py_actions/tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import asyncio
import importlib
Expand All @@ -8,7 +8,6 @@
import subprocess
import sys
from asyncio.subprocess import Process
from io import open
from pkgutil import iter_modules
from types import FunctionType
from typing import Any, Dict, Generator, List, Match, Optional, TextIO, Tuple, Union
Expand Down Expand Up @@ -396,7 +395,11 @@ async def read_interactive_stream() -> Optional[str]:
last_line = ''

try:
with open(output_filename, 'w', encoding='utf8') as output_file:
# The command output from asyncio stream already contains OS specific line ending,
# because it's read in as bytes and decoded to string. On Windows "output" already
# contains CRLF. Use "newline=''" to prevent python to convert CRLF into CRCRLF.
# Please see "newline" description at https://docs.python.org/3/library/functions.html#open
with open(output_filename, 'w', encoding='utf8', newline='') as output_file:
while True:
if self.interactive:
output = await read_interactive_stream()
Expand Down

0 comments on commit f85280f

Please sign in to comment.