[pykickstart] [PATCH] Beware of possibly unicode strings (#876293)
Vratislav Podzimek
vpodzime at redhat.com
Fri Nov 30 11:13:16 UTC 2012
__str__ method should return byte string, not unicode string. But
as we don't have a check in every KS_OBJECT.__str__ method, let's at
least add try-except block to prevent UnicodeDecodeError tracebacks.
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pykickstart/base.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/pykickstart/base.py b/pykickstart/base.py
index 4ef442c..9079906 100644
--- a/pykickstart/base.py
+++ b/pykickstart/base.py
@@ -281,12 +281,20 @@ class BaseHandler(KickstartObject):
for prio in lst:
for obj in self._writeOrder[prio]:
- retval += obj.__str__()
+ obj_str = str(obj)
+ try:
+ retval += obj_str
+ except UnicodeDecodeError:
+ retval += obj_str.encode("utf-8")
for script in self.scripts:
- retval += script.__str__()
+ script_str = str(script)
+ try:
+ retval += script_str
+ except UnicodeDecodeError:
+ retval += script_str.encode("utf-8")
- retval += self.packages.__str__()
+ retval += str(self.packages)
return retval
--
1.7.11.7
More information about the anaconda-patches
mailing list