Skip to content

Commit 7d14cf9

Browse files
uranusjrindygreg
authored andcommitted
windows: encoding fixes
1 parent f63a9d3 commit 7d14cf9

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

cpython-windows/build.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def add_to_config_c(source_path: pathlib.Path, extension: str, init_fn: str):
160160

161161
lines = []
162162

163-
with config_c_path.open('r') as fh:
163+
with config_c_path.open('r', encoding='utf8') as fh:
164164
for line in fh:
165165
line = line.rstrip()
166166

@@ -176,7 +176,7 @@ def add_to_config_c(source_path: pathlib.Path, extension: str, init_fn: str):
176176

177177
lines.append(line)
178178

179-
with config_c_path.open('w') as fh:
179+
with config_c_path.open('w', encoding='utf8') as fh:
180180
fh.write('\n'.join(lines))
181181

182182

@@ -193,7 +193,7 @@ def remove_from_extension_modules(source_path: pathlib.Path, extension: str):
193193

194194
lines = []
195195

196-
with pcbuild_proj_path.open('r') as fh:
196+
with pcbuild_proj_path.open('r', encoding='utf8') as fh:
197197
for line in fh:
198198
line = line.rstrip()
199199

@@ -210,7 +210,7 @@ def remove_from_extension_modules(source_path: pathlib.Path, extension: str):
210210

211211
lines.append(line)
212212

213-
with pcbuild_proj_path.open('w') as fh:
213+
with pcbuild_proj_path.open('w', encoding='utf8') as fh:
214214
fh.write('\n'.join(lines))
215215

216216

@@ -223,7 +223,7 @@ def make_project_static_library(source_path: pathlib.Path, project: str):
223223
found_config_type = False
224224
found_target_ext = False
225225

226-
with proj_path.open('r') as fh:
226+
with proj_path.open('r', encoding='utf8') as fh:
227227
for line in fh:
228228
line = line.rstrip()
229229

@@ -254,7 +254,7 @@ def make_project_static_library(source_path: pathlib.Path, project: str):
254254
log('failed to adjust target extension for %s' % project)
255255
sys.exit(1)
256256

257-
with proj_path.open('w') as fh:
257+
with proj_path.open('w', encoding='utf8') as fh:
258258
fh.write('\n'.join(lines))
259259

260260

@@ -281,7 +281,7 @@ def convert_to_static_library(source_path: pathlib.Path, extension: str, entry:
281281
itemgroup_line = None
282282
itemdefinitiongroup_line = None
283283

284-
with proj_path.open('r') as fh:
284+
with proj_path.open('r', encoding='utf8') as fh:
285285
for i, line in enumerate(fh):
286286
line = line.rstrip()
287287

@@ -362,7 +362,7 @@ def convert_to_static_library(source_path: pathlib.Path, extension: str, entry:
362362

363363
lines = lines[:start_line] + lines[end_line + 1:]
364364

365-
with proj_path.open('w') as fh:
365+
with proj_path.open('w', encoding='utf8') as fh:
366366
fh.write('\n'.join(lines))
367367

368368
# Tell pythoncore to link against the static .lib.
@@ -371,7 +371,7 @@ def convert_to_static_library(source_path: pathlib.Path, extension: str, entry:
371371
pythoncore_path = source_path / 'PCbuild' / 'pythoncore.vcxproj'
372372
lines = []
373373

374-
with pythoncore_path.open('r') as fh:
374+
with pythoncore_path.open('r', encoding='utf8') as fh:
375375
for line in fh:
376376
line = line.rstrip()
377377

@@ -389,7 +389,7 @@ def convert_to_static_library(source_path: pathlib.Path, extension: str, entry:
389389

390390
lines.append(line)
391391

392-
with pythoncore_path.open('w') as fh:
392+
with pythoncore_path.open('w', encoding='utf8') as fh:
393393
fh.write('\n'.join(lines))
394394

395395
# Change pythoncore to depend on the extension project.
@@ -401,13 +401,13 @@ def convert_to_static_library(source_path: pathlib.Path, extension: str, entry:
401401

402402
pcbuild_proj_path = source_path / 'PCbuild' / 'pcbuild.proj'
403403

404-
with pcbuild_proj_path.open('r') as fh:
404+
with pcbuild_proj_path.open('r', encoding='utf8') as fh:
405405
data = fh.read()
406406

407407
data = data.replace('<Projects Include="pythoncore.vcxproj">',
408408
' <Projects Include="%s.vcxproj" />\n <Projects Include="pythoncore.vcxproj">' % extension)
409409

410-
with pcbuild_proj_path.open('w') as fh:
410+
with pcbuild_proj_path.open('w', encoding='utf8') as fh:
411411
fh.write(data)
412412

413413
# We don't technically need to modify the solution since msbuild doesn't
@@ -421,7 +421,7 @@ def convert_to_static_library(source_path: pathlib.Path, extension: str, entry:
421421
extension_id = None
422422
pythoncore_line = None
423423

424-
with pcbuild_sln_path.open('r') as fh:
424+
with pcbuild_sln_path.open('r', encoding='utf8') as fh:
425425
# First pass buffers the file, finds the ID of the extension project,
426426
# and finds where the pythoncore project is defined.
427427
for i, line in enumerate(fh):
@@ -457,7 +457,7 @@ def convert_to_static_library(source_path: pathlib.Path, extension: str, entry:
457457
lines.insert(pythoncore_line + 1, '\tProjectSection(ProjectDependencies) = postProject')
458458
lines.insert(pythoncore_line + 3, '\tEndProjectSection')
459459

460-
with pcbuild_sln_path.open('w') as fh:
460+
with pcbuild_sln_path.open('w', encoding='utf8') as fh:
461461
fh.write('\n'.join(lines))
462462

463463

@@ -468,7 +468,7 @@ def copy_link_to_lib(p: pathlib.Path):
468468
copy_lines = []
469469
copy_active = False
470470

471-
with p.open('r') as fh:
471+
with p.open('r', encoding='utf8') as fh:
472472
for line in fh:
473473
line = line.rstrip()
474474

@@ -489,7 +489,7 @@ def copy_link_to_lib(p: pathlib.Path):
489489
if copy_active:
490490
copy_lines.append(line)
491491

492-
with p.open('w') as fh:
492+
with p.open('w', encoding='utf8') as fh:
493493
fh.write('\n'.join(lines))
494494

495495

@@ -1106,7 +1106,7 @@ def process_project(project: pathlib.Path, dest_dir: pathlib.Path):
11061106
def find_additional_dependencies(project: pathlib.Path):
11071107
vcproj = pcbuild_path / ('%s.vcxproj' % project)
11081108

1109-
with vcproj.open('r') as fh:
1109+
with vcproj.open('r', encoding='utf8') as fh:
11101110
for line in fh:
11111111
m = RE_ADDITIONAL_DEPENDENCIES.search(line)
11121112

@@ -1259,7 +1259,7 @@ def build_cpython(pgo=False):
12591259
# Parse config.c before we hack it up: we want a pristine copy.
12601260
config_c_path = cpython_source_path / 'PC' / 'config.c'
12611261

1262-
with config_c_path.open('r') as fh:
1262+
with config_c_path.open('r', encoding='utf8') as fh:
12631263
config_c = fh.read()
12641264

12651265
builtin_extensions = parse_config_c(config_c)
@@ -1361,7 +1361,7 @@ def build_cpython(pgo=False):
13611361
'build_info': build_info,
13621362
}
13631363

1364-
with (out_dir / 'python' / 'PYTHON.json').open('w') as fh:
1364+
with (out_dir / 'python' / 'PYTHON.json').open('w', encoding='utf8') as fh:
13651365
json.dump(python_info, fh, sort_keys=True, indent=4)
13661366

13671367
# Copy software licenses file.

0 commit comments

Comments
 (0)