From b7522c5a1cce67d1b2af63f1e85ee84e145c166b Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 24 Aug 2016 11:14:45 -0700 Subject: [PATCH] Fix hg for python3 (#4528) * Remove import of unused ConfigParser (ConfigParser has been renamed in py3) * When retrieving version, normalize to a native string --- lib/ansible/modules/source_control/hg.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/source_control/hg.py b/lib/ansible/modules/source_control/hg.py index 827a12d7765..5f279e1a9ed 100644 --- a/lib/ansible/modules/source_control/hg.py +++ b/lib/ansible/modules/source_control/hg.py @@ -23,8 +23,6 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -import ConfigParser - DOCUMENTATION = ''' --- module: hg @@ -92,6 +90,12 @@ EXAMPLES = ''' - hg: repo=https://bitbucket.org/user/repo1 dest=/home/user/repo1 revision=stable purge=yes ''' +import os + +# import module snippets +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils._text import to_native + class Hg(object): def __init__(self, module, dest, repo, revision, hg_path): @@ -123,7 +127,7 @@ class Hg(object): if rc != 0: self.module.fail_json(msg=err) else: - return out.strip('\n') + return to_native(out).strip('\n') def has_local_mods(self): now = self.get_revision() @@ -270,6 +274,5 @@ def main(): changed = True module.exit_json(before=before, after=after, changed=changed, cleaned=cleaned) -# import module snippets -from ansible.module_utils.basic import * -main() +if __name__ == '__main__': + main()