[Python-checkins] bpo-41754: Ignore NotADirectoryError in invocation of xdg-settings (GH-23075) (GH-23198)

ronaldoussoren webhook-mailer at python.org
Sun Nov 8 07:06:21 EST 2020


https://github.com/python/cpython/commit/db087f6d9ef9a7c873cd883ee120126fc0ca0c72
commit: db087f6d9ef9a7c873cd883ee120126fc0ca0c72
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ronaldoussoren <ronaldoussoren at mac.com>
date: 2020-11-08T13:06:17+01:00
summary:

bpo-41754: Ignore NotADirectoryError in invocation of xdg-settings (GH-23075) (GH-23198)

It is not clear why this can happen, but several users have mentioned
getting this exception on macOS.
(cherry picked from commit 23831a7a90956e38b7d70304bb6afe30d37936de)

Co-authored-by: Ronald Oussoren <ronaldoussoren at mac.com>

Co-authored-by: Ronald Oussoren <ronaldoussoren at mac.com>

files:
A Misc/NEWS.d/next/Library/2020-11-01-15-07-20.bpo-41754.DraSZh.rst
M Lib/webbrowser.py

diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index cea91308ce1b3..6023c1e13841d 100755
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -550,7 +550,7 @@ def register_standard_browsers():
                 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
diff --git a/Misc/NEWS.d/next/Library/2020-11-01-15-07-20.bpo-41754.DraSZh.rst b/Misc/NEWS.d/next/Library/2020-11-01-15-07-20.bpo-41754.DraSZh.rst
new file mode 100644
index 0000000000000..181c2d9650a14
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-11-01-15-07-20.bpo-41754.DraSZh.rst
@@ -0,0 +1 @@
+webbrowser: Ignore *NotADirectoryError* when calling ``xdg-settings``.



More information about the Python-checkins mailing list