mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Ensure that current uses of BaseException are required
* In some cases, it appears that Exception should have been used instead as there's no need to catch sys.exit KeyboardInterrupt and similar. * In a few cases, it appears that BaseException is used because a library we depend on calls sys.exit() contrary to good coding design. Comment those so that we know that those have been audited and found to be correct and change to use (Exception, SystemExit) instead.
This commit is contained in:
parent
3fba006207
commit
175f3b51e5
9 changed files with 31 additions and 20 deletions
|
@ -84,12 +84,12 @@ def get_hostname():
|
|||
def get_ip():
|
||||
try:
|
||||
return socket.gethostbyname(get_hostname())
|
||||
except BaseException:
|
||||
except Exception:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
try:
|
||||
s.connect(('10.255.255.255', 1))
|
||||
IP = s.getsockname()[0]
|
||||
except BaseException:
|
||||
except Exception:
|
||||
IP = '127.0.0.1'
|
||||
finally:
|
||||
s.close()
|
||||
|
@ -101,7 +101,7 @@ def isJSONable(obj):
|
|||
try:
|
||||
json.dumps(obj, sort_keys=True, cls=AnsibleJSONEncoder)
|
||||
return True
|
||||
except BaseException:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
|
@ -165,7 +165,7 @@ class CallbackModule(CallbackBase):
|
|||
def sanitizeJSON(self, data):
|
||||
try:
|
||||
return json.loads(json.dumps(data, sort_keys=True, cls=AnsibleJSONEncoder))
|
||||
except BaseException:
|
||||
except Exception:
|
||||
return {'warnings': ['JSON Formatting Issue', json.dumps(data, sort_keys=True, cls=AnsibleJSONEncoder)]}
|
||||
|
||||
def flush(self, log, options):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue