From e7d0c545aa2fbe204bf2b1f7feec6cd4a2490d2b Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 23 Nov 2014 17:09:48 +0000 Subject: [PATCH] Py3 compatibility fixes. --- salt/utils/decorators/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/salt/utils/decorators/__init__.py b/salt/utils/decorators/__init__.py index 0a7ab0a634..bc822bbc1a 100644 --- a/salt/utils/decorators/__init__.py +++ b/salt/utils/decorators/__init__.py @@ -3,9 +3,8 @@ Helpful decorators module writing ''' -from __future__ import absolute_import - # Import python libs +from __future__ import absolute_import import inspect import logging from functools import wraps @@ -15,6 +14,9 @@ from collections import defaultdict import salt.utils from salt.exceptions import CommandNotFoundError +# Import 3rd-party libs +import salt.ext.six as six + log = logging.getLogger(__name__) @@ -74,7 +76,7 @@ class Depends(object): It will modify the "functions" dict and remove/replace modules that are missing dependencies. ''' - for dependency, dependent_set in cls.dependency_dict.items(): + for dependency, dependent_set in six.iteritems(cls.dependency_dict): # check if dependency is loaded for module, func, fallback_function in dependent_set: # check if you have the dependency @@ -183,7 +185,7 @@ def identical_signature_wrapper(original_function, wrapped_function): '', 'exec' ) - exec(function_def, context) + six.exec_(function_def, context) return wraps(original_function)(context[original_function.__name__])