Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

tools: privacy.py writes its list as UTF-8, so a Unicode name no longer stops it on Windows

LOKI8566d9189cce
diff --git a/tests/test_privacy_write_target_first.py b/tests/test_privacy_write_target_first.py
index 1a020cc9b..c917f0ea5 100644
--- a/tests/test_privacy_write_target_first.py
+++ b/tests/test_privacy_write_target_first.py
@@ -169,13 +169,16 @@ class PrivacyWriteTargetTest(unittest.TestCase):
self.state_path.write_text(json.dumps(state))
def write(self, target, *args, hook=None):
- env = dict(os.environ, TV_HOST="192.168.1.50", FAKE_TV_STATE=str(self.state_path))
+ # The fake tv.py does not reconfigure the streams as the real one does, so name UTF-8 for the
+ # Unicode paths of the test below; a Windows pipe would otherwise use the ANSI code page.
+ env = dict(os.environ, TV_HOST="192.168.1.50", FAKE_TV_STATE=str(self.state_path),
+ PYTHONIOENCODING="utf-8")
command = [sys.executable, str(self.script), "--write", str(target), *args]
if hook:
env.update(PRIVACY_WRITE_HOOK=hook, PRIVACY_SENTINEL=SENTINEL.hex())
command = [sys.executable, "-c", WRITE_HOOK, *command[1:]]
return subprocess.run(command,
- cwd=self.repo, env=env, capture_output=True, text=True,
+ cwd=self.repo, env=env, capture_output=True, text=True, encoding="utf-8",
stdin=subprocess.DEVNULL, timeout=120)
def symlink(self, link, target):
diff --git a/tools/privacy.py b/tools/privacy.py
index cce717fc5..b6e95de8c 100644
--- a/tools/privacy.py
+++ b/tools/privacy.py
@@ -443,8 +443,9 @@ def write_list(path, result, include_low):
# entries, including dangling symlinks which open("x") can follow on Windows.
staged = None
try:
- with tempfile.NamedTemporaryFile(mode="w", prefix=".privacy-", suffix=".tmp",
- dir=os.path.dirname(path) or ".", delete=False) as f:
+ with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8", prefix=".privacy-",
+ suffix=".tmp", dir=os.path.dirname(path) or ".",
+ delete=False) as f:
staged = f.name
f.write(text)
os.rename(staged, path)
@@ -458,7 +459,7 @@ def write_list(path, result, include_low):
else:
# A failed write may leave this newly created file. Do not unlink a path another
# process could have replaced after creation.
- with open(path, "x") as f:
+ with open(path, "x", encoding="utf-8") as f:
f.write(text)
except OSError as error:
# The audit is two shell calls for each package it probed, slow on old firmware: a file the