diff --git a/tools/test-locked-requirements b/tools/test-locked-requirements index e98b7eb99a..7172f68e2f 100755 --- a/tools/test-locked-requirements +++ b/tools/test-locked-requirements @@ -57,8 +57,8 @@ def get_requirements_hash(tmp_dir: str, use_test_lock_files: bool = False) -> st lock_files_path = tmp_dir reqs_files.extend(sorted(glob.glob(os.path.join(lock_files_path, "*.txt")))) for file_path in reqs_files: - with open(file_path) as fp: - sha1.update(fp.read().encode("utf-8")) + with open(file_path, 'rb') as fp: + sha1.update(fp.read()) return sha1.hexdigest() def may_be_setup_cache() -> None: diff --git a/tools/test-run-dev b/tools/test-run-dev index f7d882373f..7c1f17296d 100755 --- a/tools/test-run-dev +++ b/tools/test-run-dev @@ -16,11 +16,11 @@ def start_server(logfile_name: str) -> Tuple[bool, str]: failure = True key = "Quit the server with CTRL-C." datalog = [] - with open(logfile_name, 'rb', buffering=0) as logfile: + with open(logfile_name, 'r', buffering=0) as logfile: for i in range(200): time.sleep(0.5) print(f"{i}. Polling run-dev...") - new_data = logfile.read().decode() + new_data = logfile.read() if new_data: datalog.append(new_data) diff --git a/tools/zulip-export/zulip-export b/tools/zulip-export/zulip-export index 98dbf16ecf..fcc1b2e6de 100755 --- a/tools/zulip-export/zulip-export +++ b/tools/zulip-export/zulip-export @@ -78,7 +78,7 @@ for msg in result['messages']: messages.append(msg) filename = f"zulip-{options.stream}.json" -with open(filename, 'wb') as f: - f.write(json.dumps(messages, indent=0, sort_keys=False).encode('utf-8')) +with open(filename, 'w') as f: + json.dump(messages, f, indent=0, sort_keys=False) print(f"{len(messages)} messages exported to {filename}") sys.exit(0) diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.py index 4013755640..902254df34 100644 --- a/zerver/worker/queue_processors.py +++ b/zerver/worker/queue_processors.py @@ -329,8 +329,8 @@ class QueueProcessingWorker(ABC): line = f'{time.asctime()}\t{orjson.dumps(events).decode()}\n' lock_fn = fn + '.lock' with lockfile(lock_fn): - with open(fn, 'ab') as f: - f.write(line.encode('utf-8')) + with open(fn, 'a') as f: + f.write(line) check_and_send_restart_signal() def setup(self) -> None: