Merge pull request #1164 from cclauss/use-new-style-exceptions

Modernize Python 2 code to get ready for Python 3
This commit is contained in:
Ryan Petrello
2018-02-08 14:10:25 -05:00
committed by GitHub
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

@@ -2045,7 +2045,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)