From 9728d8960f1b10502365cbdb414c16442fca7d05 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 30 Jul 2020 15:40:13 +0100 Subject: [PATCH] Ignore PermissionError in netrc_info() (#1104) * Ignore PermissionError in netrc_info() --- httpx/_utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/httpx/_utils.py b/httpx/_utils.py index 55503655d3..f01cfe4ecc 100644 --- a/httpx/_utils.py +++ b/httpx/_utils.py @@ -139,9 +139,13 @@ def netrc_info(self) -> typing.Optional[netrc.netrc]: self._netrc_info = None for file_path in self.netrc_files: expanded_path = Path(file_path).expanduser() - if expanded_path.is_file(): - self._netrc_info = netrc.netrc(str(expanded_path)) - break + try: + if expanded_path.is_file(): + self._netrc_info = netrc.netrc(str(expanded_path)) + break + except (netrc.NetrcParseError, IOError): # pragma: nocover + # Issue while reading the netrc file, ignore... + pass return self._netrc_info def get_credentials(