]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Ignore PermissionError in netrc_info() (#1104)
authorTom Christie <tom@tomchristie.com>
Thu, 30 Jul 2020 14:40:13 +0000 (15:40 +0100)
committerGitHub <noreply@github.com>
Thu, 30 Jul 2020 14:40:13 +0000 (15:40 +0100)
* Ignore PermissionError in netrc_info()

httpx/_utils.py

index 55503655d32df4aa9694bf6704caa8e4c65b16dc..f01cfe4ecc5dbfdf1347c81214df3f8ba8535728 100644 (file)
@@ -139,9 +139,13 @@ class NetRCInfo:
             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(