Skip to content

Commit 0657363

Browse files
committed
encoding
1 parent 84c3cb4 commit 0657363

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/semiwrap/cmd_genmeson.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ def gen_meson_to_file(
403403
pathlib.Path(project_root), stage0, stage1, trampolines
404404
)
405405

406-
maybe_write_file(stage0, s0_content)
407-
maybe_write_file(stage1, s1_content)
408-
maybe_write_file(trampolines, t_content)
406+
maybe_write_file(stage0, s0_content, encoding="utf-8")
407+
maybe_write_file(stage1, s1_content, encoding="utf-8")
408+
maybe_write_file(trampolines, t_content, encoding="utf-8")
409409

410410
return eps
411411

src/semiwrap/makeplan.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ def _locate_type_caster_json(
370370
while to_check:
371371
name = to_check.popleft()
372372
checked.add(name)
373-
print("checking", name)
374373

375374
entry = self.pkgcache.get(name)
376375

src/semiwrap/util.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import pathlib
2+
import typing as T
23

34

4-
def maybe_write_file(path: pathlib.Path, content: str) -> bool:
5+
def maybe_write_file(
6+
path: pathlib.Path, content: str, *, encoding: T.Optional[str] = None
7+
) -> bool:
58
# returns True if new content written
69
if path.exists():
7-
with open(path) as fp:
10+
with open(path, encoding=encoding) as fp:
811
oldcontent = fp.read()
912
if oldcontent == content:
1013
return False
1114
elif not path.parent.exists():
1215
path.parent.mkdir(parents=True)
1316

14-
with open(path, "w") as fp:
17+
with open(path, "w", encoding=encoding) as fp:
1518
fp.write(content)
1619

1720
return True

0 commit comments

Comments
 (0)