From 7ce1692eef82880e60c921196862a2b01db42c77 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 14 Nov 2021 23:00:08 -0800 Subject: [PATCH] windows: default version to '0' when looking for Ghostscript To avoid ValueError: max() arg is an empty sequence As suggested by @meet1919 in #833. --- src/ocrmypdf/subprocess/_windows.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ocrmypdf/subprocess/_windows.py b/src/ocrmypdf/subprocess/_windows.py index c3130a7d..56211eb8 100644 --- a/src/ocrmypdf/subprocess/_windows.py +++ b/src/ocrmypdf/subprocess/_windows.py @@ -51,7 +51,7 @@ def registry_path_ghostscript(env=None) -> Iterator[Path]: with winreg.OpenKey( winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Artifex\GPL Ghostscript" ) as k: - latest_gs = max(registry_subkeys(k), key=LooseVersion) + latest_gs = max(registry_subkeys(k), key=LooseVersion, default='0') with winreg.OpenKey( winreg.HKEY_LOCAL_MACHINE, fr"SOFTWARE\Artifex\GPL Ghostscript\{latest_gs}" ) as k: