summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-03-13 11:49:58 +0100
committerGitHub <noreply@github.com>2018-03-13 11:49:58 +0100
commit4287c7822b8aa06b069e42b44b9aa73396db62f5 (patch)
tree2db4764933bbf252b8ba0007816527265f4dd79d /core
parent6e491ff283b7cfa90a1e27e96edb0b7c9dececa6 (diff)
parent272ecddb2859e3c184886bc2d142e2e329b8ae83 (diff)
Merge pull request #17440 from viktor-ferenczi/issue-5042
Properly closing all files in Python build code
Diffstat (limited to 'core')
-rw-r--r--core/SCsub10
-rw-r--r--core/make_binders.py10
2 files changed, 8 insertions, 12 deletions
diff --git a/core/SCsub b/core/SCsub
index 1545bc8aeb..383aaf0e12 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -18,9 +18,8 @@ gd_cpp = '#include "project_settings.h"\n'
gd_cpp += gd_inc
gd_cpp += "void ProjectSettings::register_global_defaults() {\n" + gd_call + "\n}\n"
-f = open("global_defaults.gen.cpp", "w")
-f.write(gd_cpp)
-f.close()
+with open("global_defaults.gen.cpp", "w") as f:
+ f.write(gd_cpp)
# Generate AES256 script encryption key
@@ -47,9 +46,8 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ):
txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0"
print("Invalid AES256 encryption key, not 64 bits hex: " + e)
-f = open("script_encryption_key.gen.cpp", "w")
-f.write("#include \"project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
-f.close()
+with open("script_encryption_key.gen.cpp", "w") as f:
+ f.write("#include \"project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n")
# Add required thirdparty code. Header paths are hardcoded, we don't need to append
diff --git a/core/make_binders.py b/core/make_binders.py
index 1e581f8ce3..6a7602cd5d 100644
--- a/core/make_binders.py
+++ b/core/make_binders.py
@@ -265,10 +265,8 @@ def run(target, source, env):
else:
text += t
- f = open(target[0].path, "w")
- f.write(text)
- f.close()
+ with open(target[0].path, "w") as f:
+ f.write(text)
- f = open(target[1].path, "w")
- f.write(text_ext)
- f.close()
+ with open(target[1].path, "w") as f:
+ f.write(text_ext)