Fix dircolors NotADirectoryError (#5300)

* Update environ.py

* Create fix_dircolors_NotADirectoryError.rst
This commit is contained in:
Andy Kipp 2024-03-11 21:53:50 +01:00 committed by GitHub
parent f5ae75268a
commit 5fd9a25d09
Failed to generate hash of commit
2 changed files with 24 additions and 1 deletions

View file

@ -0,0 +1,23 @@
**Added:**
* <news item>
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* Fixed NotADirectoryError during load dircolors.
**Security:**
* <news item>

View file

@ -485,7 +485,7 @@ class LsColors(cabc.MutableMapping):
out = subprocess.check_output(
cmd, env=denv, text=True, stderr=subprocess.DEVNULL
)
except (subprocess.CalledProcessError, FileNotFoundError):
except (subprocess.CalledProcessError, FileNotFoundError, NotADirectoryError):
return cls(cls.default_settings)
except OSError:
# necessary to catch OSError: [WinError 740] The requested operation requires elevation