Skip to content

Commit 0ace0a1

Browse files
committed
Merge pull request #89333 from Repiteo/enforce-eol-python
Enforce `\n` eol for Python writes
2 parents 7d6ae13 + d9fa40f commit 0ace0a1

30 files changed

+63
-59
lines changed

core/SCsub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if "SCRIPT_AES256_ENCRYPTION_KEY" in os.environ:
3636
Exit(255)
3737

3838
# NOTE: It is safe to generate this file here, since this is still executed serially
39-
with open("script_encryption_key.gen.cpp", "w") as f:
39+
with open("script_encryption_key.gen.cpp", "w", encoding="utf-8", newline="\n") as f:
4040
f.write('#include "core/config/project_settings.h"\nuint8_t script_encryption_key[32]={' + txt + "};\n")
4141

4242

core/core_builders.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def make_certs_header(target, source, env):
3232
src = source[0]
3333
dst = target[0]
3434
f = open(src, "rb")
35-
g = open(dst, "w", encoding="utf-8")
35+
g = open(dst, "w", encoding="utf-8", newline="\n")
3636
buf = f.read()
3737
decomp_size = len(buf)
3838

@@ -79,7 +79,7 @@ def make_authors_header(target, source, env):
7979
src = source[0]
8080
dst = target[0]
8181
f = open(src, "r", encoding="utf-8")
82-
g = open(dst, "w", encoding="utf-8")
82+
g = open(dst, "w", encoding="utf-8", newline="\n")
8383

8484
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
8585
g.write("#ifndef AUTHORS_GEN_H\n")
@@ -141,7 +141,7 @@ def make_donors_header(target, source, env):
141141
src = source[0]
142142
dst = target[0]
143143
f = open(src, "r", encoding="utf-8")
144-
g = open(dst, "w", encoding="utf-8")
144+
g = open(dst, "w", encoding="utf-8", newline="\n")
145145

146146
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
147147
g.write("#ifndef DONORS_GEN_H\n")
@@ -239,7 +239,7 @@ def next_tag(self):
239239
part["copyright_index"] = len(data_list)
240240
data_list += part["Copyright"]
241241

242-
with open(dst, "w", encoding="utf-8") as f:
242+
with open(dst, "w", encoding="utf-8", newline="\n") as f:
243243
f.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
244244
f.write("#ifndef LICENSE_GEN_H\n")
245245
f.write("#define LICENSE_GEN_H\n")

core/extension/make_interface_dumper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def run(target, source, env):
55
src = source[0]
66
dst = target[0]
77
f = open(src, "rb")
8-
g = open(dst, "w", encoding="utf-8")
8+
g = open(dst, "w", encoding="utf-8", newline="\n")
99

1010
buf = f.read()
1111
decomp_size = len(buf)

core/extension/make_wrappers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def run(target, source, env):
142142

143143
txt += "\n#endif\n"
144144

145-
with open(target[0], "w") as f:
145+
with open(target[0], "w", encoding="utf-8", newline="\n") as f:
146146
f.write(txt)
147147

148148

core/input/input_builders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
def make_default_controller_mappings(target, source, env):
1111
dst = target[0]
12-
g = open(dst, "w")
12+
g = open(dst, "w", encoding="utf-8", newline="\n")
1313

1414
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
1515
g.write('#include "core/typedefs.h"\n')

core/object/make_virtuals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def run(target, source, env):
201201

202202
txt += "#endif // GDVIRTUAL_GEN_H\n"
203203

204-
with open(target[0], "w") as f:
204+
with open(target[0], "w", encoding="utf-8", newline="\n") as f:
205205
f.write(txt)
206206

207207

doc/tools/make_rst.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -891,9 +891,9 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
891891
class_name = class_def.name
892892

893893
if dry_run:
894-
f = open(os.devnull, "w", encoding="utf-8")
894+
f = open(os.devnull, "w", encoding="utf-8", newline="\n")
895895
else:
896-
f = open(os.path.join(output_dir, f"class_{class_name.lower()}.rst"), "w", encoding="utf-8")
896+
f = open(os.path.join(output_dir, f"class_{class_name.lower()}.rst"), "w", encoding="utf-8", newline="\n")
897897

898898
# Remove the "Edit on Github" button from the online docs page.
899899
f.write(":github_url: hide\n\n")
@@ -1691,9 +1691,9 @@ def make_link(url: str, title: str) -> str:
16911691

16921692
def make_rst_index(grouped_classes: Dict[str, List[str]], dry_run: bool, output_dir: str) -> None:
16931693
if dry_run:
1694-
f = open(os.devnull, "w", encoding="utf-8")
1694+
f = open(os.devnull, "w", encoding="utf-8", newline="\n")
16951695
else:
1696-
f = open(os.path.join(output_dir, "index.rst"), "w", encoding="utf-8")
1696+
f = open(os.path.join(output_dir, "index.rst"), "w", encoding="utf-8", newline="\n")
16971697

16981698
# Remove the "Edit on Github" button from the online docs page, and disallow user-contributed notes
16991699
# on the index page. User-contributed notes are allowed on individual class pages.

editor/SCsub

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import editor_builders
1111

1212
def _make_doc_data_class_path(to_path):
1313
# NOTE: It is safe to generate this file here, since this is still executed serially
14-
g = open(os.path.join(to_path, "doc_data_class_path.gen.h"), "w", encoding="utf-8")
14+
g = open(os.path.join(to_path, "doc_data_class_path.gen.h"), "w", encoding="utf-8", newline="\n")
1515
g.write("static const int _doc_data_class_path_count = " + str(len(env.doc_class_path)) + ";\n")
1616
g.write("struct _DocDataClassPath { const char* name; const char* path; };\n")
1717

@@ -41,7 +41,7 @@ if env.editor_build:
4141
reg_exporters += "}\n"
4242

4343
# NOTE: It is safe to generate this file here, since this is still executed serially
44-
with open("register_exporters.gen.cpp", "w", encoding="utf-8") as f:
44+
with open("register_exporters.gen.cpp", "w", encoding="utf-8", newline="\n") as f:
4545
f.write(reg_exporters_inc)
4646
f.write(reg_exporters)
4747

editor/editor_builders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
def make_doc_header(target, source, env):
1818
dst = target[0]
19-
g = open(dst, "w", encoding="utf-8")
19+
g = open(dst, "w", encoding="utf-8", newline="\n")
2020
buf = ""
2121
docbegin = ""
2222
docend = ""
@@ -53,7 +53,7 @@ def make_doc_header(target, source, env):
5353
def make_translations_header(target, source, env, category):
5454
dst = target[0]
5555

56-
g = open(dst, "w", encoding="utf-8")
56+
g = open(dst, "w", encoding="utf-8", newline="\n")
5757

5858
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
5959
g.write("#ifndef _{}_TRANSLATIONS_H\n".format(category.upper()))

editor/icons/editor_icons_builders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def make_editor_icons_action(target, source, env):
8585

8686
s.write("#endif\n")
8787

88-
with open(dst, "w") as f:
88+
with open(dst, "w", encoding="utf-8", newline="\n") as f:
8989
f.write(s.getvalue())
9090

9191
s.close()

0 commit comments

Comments
 (0)