mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-13 12:21:12 +00:00
Use isinstance instead of type() comparisons. isinstance is more robust
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from collections import MutableMapping
|
||||
|
||||
from ansible.utils.vars import merge_hash
|
||||
|
||||
class AggregateStats:
|
||||
@@ -73,10 +75,10 @@ class AggregateStats:
|
||||
return self.set_custom_stats(which, what, host)
|
||||
|
||||
# mismatching types
|
||||
if type(what) != type(self.custom[host][which]):
|
||||
if not isinstance(what, type(self.custom[host][which])):
|
||||
return None
|
||||
|
||||
if isinstance(what, dict):
|
||||
if isinstance(what, MutableMapping):
|
||||
self.custom[host][which] = merge_hash(self.custom[host][which], what)
|
||||
else:
|
||||
# let overloaded + take care of other types
|
||||
|
||||
@@ -144,7 +144,7 @@ class Debugger(cmd.Cmd):
|
||||
exec(code, globals(), self.scope)
|
||||
except:
|
||||
t, v = sys.exc_info()[:2]
|
||||
if type(t) == type(''):
|
||||
if isinstance(t, str):
|
||||
exc_type_name = t
|
||||
else:
|
||||
exc_type_name = t.__name__
|
||||
|
||||
Reference in New Issue
Block a user