It is not clear why this can happen, but several users have mentioned
getting this exception on macOS.
cmd = "xdg-settings get default-web-browser".split()
raw_result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
result = raw_result.decode().strip()
- except (FileNotFoundError, subprocess.CalledProcessError, PermissionError) :
+ except (FileNotFoundError, subprocess.CalledProcessError, PermissionError, NotADirectoryError) :
pass
else:
global _os_preferred_browser
--- /dev/null
+webbrowser: Ignore *NotADirectoryError* when calling ``xdg-settings``.