Skip to content

Commit 7a5417a

Browse files
committed
cli: Fix piping .py file from stdin.
When we fixed explicit text encoding for text files, we accidentally changed one NamedTemporaryFile to text mode. Change it back to binary mode. Fixes: pybricks/support#2325
1 parent 284937f commit 7a5417a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
- Fixed piping text files to `pybricksdev run` from stdin.
11+
912
## [2.0.0] - 2025-08-10
1013

1114
### Added

pybricksdev/cli/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ def _get_script_path(file: TextIO) -> ContextManager[PathLike]:
6868
@contextlib.contextmanager
6969
def temp_context():
7070
try:
71-
with NamedTemporaryFile(
72-
suffix=".py", delete=False, encoding="utf-8"
73-
) as temp:
71+
with NamedTemporaryFile("wb", suffix=".py", delete=False) as temp:
7472
temp.write(file.buffer.read())
7573

7674
yield temp.name

0 commit comments

Comments
 (0)