Modernize Python 2 code to get ready for Python 3

This commit is contained in:
cclauss
2018-02-08 16:39:06 +01:00
parent e982f6ed06
commit e18838a4b7
16 changed files with 28 additions and 29 deletions

View File

@@ -33,7 +33,7 @@ class OrderedDictLoader(yaml.SafeLoader):
key = self.construct_object(key_node, deep=deep)
try:
hash(key)
except TypeError, exc:
except TypeError as exc:
raise yaml.constructor.ConstructorError(
"while constructing a mapping", node.start_mark,
"found unacceptable key (%s)" % exc, key_node.start_mark

View File

@@ -1173,7 +1173,7 @@ class InventorySerializer(BaseSerializerWithVariables):
if host_filter:
try:
SmartFilter().query_from_string(host_filter)
except RuntimeError, e:
except RuntimeError as e:
raise models.base.ValidationError(e)
return host_filter

View File

@@ -2042,7 +2042,7 @@ class InventoryDetail(ControlledByScmMixin, RetrieveUpdateDestroyAPIView):
try:
obj.schedule_deletion(getattr(request.user, 'id', None))
return Response(status=status.HTTP_202_ACCEPTED)
except RuntimeError, e:
except RuntimeError as e:
return Response(dict(error=_("{0}".format(e))), status=status.HTTP_400_BAD_REQUEST)