From ae824fb2fc2770c84cc34c1956e4c76c8c972860 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 20 Oct 2023 23:32:40 +0545 Subject: cleanup: convert exceptions to OSError In Python 3, these exceptions were merged into OSError, so switch everything over to that. Change-Id: If876a28b692de5aa5c62a3bdc8c000793ce52c63 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390376 Reviewed-by: Aravind Vasudevan Commit-Queue: Mike Frysinger Tested-by: Mike Frysinger --- subcmds/sync.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'subcmds/sync.py') diff --git a/subcmds/sync.py b/subcmds/sync.py index 23098972..8460bcec 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -21,7 +21,6 @@ import multiprocessing import netrc import optparse import os -import socket import sys import tempfile import time @@ -1376,7 +1375,7 @@ later is required to fix a server side protocol bug. else: try: info = netrc.netrc() - except IOError: + except OSError: # .netrc file does not exist or could not be opened. pass else: @@ -1435,7 +1434,7 @@ later is required to fix a server side protocol bug. try: with open(smart_sync_manifest_path, "w") as f: f.write(manifest_str) - except IOError as e: + except OSError as e: raise SmartSyncError( "error: cannot write manifest to %s:\n%s" % (smart_sync_manifest_path, e), @@ -1446,7 +1445,7 @@ later is required to fix a server side protocol bug. raise SmartSyncError( "error: manifest server RPC call failed: %s" % manifest_str ) - except (socket.error, IOError, xmlrpc.client.Fault) as e: + except (OSError, xmlrpc.client.Fault) as e: raise SmartSyncError( "error: cannot connect to manifest server %s:\n%s" % (manifest.manifest_server, e), @@ -1931,7 +1930,7 @@ class _FetchTimes: try: with open(self._path) as f: self._saved = json.load(f) - except (IOError, ValueError): + except (OSError, ValueError): platform_utils.remove(self._path, missing_ok=True) self._saved = {} @@ -1947,7 +1946,7 @@ class _FetchTimes: try: with open(self._path, "w") as f: json.dump(self._seen, f, indent=2) - except (IOError, TypeError): + except (OSError, TypeError): platform_utils.remove(self._path, missing_ok=True) @@ -1994,7 +1993,7 @@ class LocalSyncState: try: with open(self._path) as f: self._state = json.load(f) - except (IOError, ValueError): + except (OSError, ValueError): platform_utils.remove(self._path, missing_ok=True) self._state = {} @@ -2004,7 +2003,7 @@ class LocalSyncState: try: with open(self._path, "w") as f: json.dump(self._state, f, indent=2) - except (IOError, TypeError): + except (OSError, TypeError): platform_utils.remove(self._path, missing_ok=True) def PruneRemovedProjects(self): @@ -2137,7 +2136,7 @@ class PersistentTransport(xmlrpc.client.Transport): try: p.feed(data) except xml.parsers.expat.ExpatError as e: - raise IOError( + raise OSError( f"Parsing the manifest failed: {e}\n" f"Please report this to your manifest server admin.\n" f'Here is the full response:\n{data.decode("utf-8")}' -- cgit v1.2.3-54-g00ecf