Skip to content

armgit / soju

Public Imported from GitHub
0

Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.

ue_driver_warning: write Engine.ini with open() so macOS's Python 3.9 works (#240)

Ege BULUT7c77a66377fc
diff --git a/scripts/ue_driver_warning.py b/scripts/ue_driver_warning.py
index 66060827484..23b3f139aa8 100644
--- a/scripts/ue_driver_warning.py
+++ b/scripts/ue_driver_warning.py
@@ -39,7 +39,10 @@ def quiet(ini):
lines.append("")
lines += ["[SystemSettings]", LINE]
try:
- ini.write_text(nl.join(lines) + nl, encoding="utf-8", newline="")
+ # open(), not Path.write_text(): write_text takes newline= only from Python 3.10, and the
+ # python3 that ships with macOS is 3.9.
+ with open(ini, "w", encoding="utf-8", newline="") as f:
+ f.write(nl.join(lines) + nl)
return True
except OSError:
return False
diff --git a/tests/test_ue_driver_warning.py b/tests/test_ue_driver_warning.py
index d6fcaab9d18..7abea724a4a 100644
--- a/tests/test_ue_driver_warning.py
+++ b/tests/test_ue_driver_warning.py
@@ -25,7 +25,7 @@ class UnrealDriverWarningTests(unittest.TestCase):
self.assertEqual(text.count(b"r.WarnOfBadDrivers=0"), 1)
self.assertIn(b"[SystemSettings]\r\nr.WarnOfBadDrivers=0\r\nr.Foo=1\r\n", text)
self.assertIn(b"[Core.System]\r\nPaths=../../Content\r\n", text)
- self.assertIn("[SystemSettings]\r\nr.WarnOfBadDrivers=0", (other / "Engine.ini").read_text(newline=""))
+ self.assertIn("[SystemSettings]\r\nr.WarnOfBadDrivers=0", (other / "Engine.ini").read_bytes().decode("utf-8"))
self.assertFalse((launcher / "Engine.ini").exists())
def test_play_sh_runs_it(self):