mirror of
https://github.com/ansible/awx.git
synced 2026-05-04 08:05:30 -02:30
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user