From 1f8575ec97de769b5408ceecdc3e80792a4e13fd Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Mon, 26 Jun 2017 19:00:51 +0530 Subject: [PATCH] Remove get_exception from zypper (#25890) Fix removes get_exception in favor of native Python exception handling. Also, added to_native to manage exception message. Signed-off-by: Abhijeet Kasurde --- lib/ansible/modules/packaging/os/zypper.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/packaging/os/zypper.py b/lib/ansible/modules/packaging/os/zypper.py index 27b7682e6fe..1194c42fb57 100644 --- a/lib/ansible/modules/packaging/os/zypper.py +++ b/lib/ansible/modules/packaging/os/zypper.py @@ -183,6 +183,7 @@ import xml import re from xml.dom.minidom import parseString as parseXML from ansible.module_utils.six import iteritems +from ansible.module_utils._text import to_native class Package: @@ -259,9 +260,8 @@ def parse_zypper_xml(m, cmd, fail_not_found=True, packages=None): try: dom = parseXML(stdout) - except xml.parsers.expat.ExpatError: - e = get_exception() - m.fail_json(msg="Failed to parse zypper xml output: %s" % e, + except xml.parsers.expat.ExpatError as exc: + m.fail_json(msg="Failed to parse zypper xml output: %s" % to_native(exc), rc=rc, stdout=stdout, stderr=stderr, cmd=cmd) if rc == 104: