URL: https://github.com/freeipa/freeipa/pull/431
Author: MartinBasti
 Title: #431: py3: ldapupdate: fix logging str(bytes) issue
Action: opened

PR body:
"""
bytes as argument of str() gives unexpected result by adding prefix "b"
there.

Also add missing safe_option() call to logging (it will fix another
str(bytes) issue)

https://fedorahosted.org/freeipa/ticket/4985


Other byteswarnings are from https://github.com/etingof/pyasn1/issues/14
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/431/head:pr431
git checkout pr431
From 5e095d19f446973cefc9c2e43d437799948a2595 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Thu, 2 Feb 2017 00:20:48 +0100
Subject: [PATCH] py3: ldapupdate: fix logging str(bytes) issue

bytes as argument of str() gives unexpected result by adding prefix "b"
there.

Also add missing safe_option() call to logging (it will fix another
str(bytes) issue)

https://fedorahosted.org/freeipa/ticket/4985
---
 ipaserver/install/ldapupdate.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/ipaserver/install/ldapupdate.py b/ipaserver/install/ldapupdate.py
index bc2673b..c6ab3e2 100644
--- a/ipaserver/install/ldapupdate.py
+++ b/ipaserver/install/ldapupdate.py
@@ -119,10 +119,10 @@ def safe_output(attr, values):
         values = [values]
 
     try:
-        all(v.decode('ascii') for v in values)
+        values = [v.decode('ascii') for v in values]
     except UnicodeDecodeError:
         try:
-            values = [base64.b64encode(v) for v in values]
+            values = [base64.b64encode(v).decode('ascii') for v in values]
         except TypeError:
             pass
 
@@ -656,7 +656,9 @@ def _apply_update_disposition(self, updates, entry):
                 try:
                     entry_values.remove(update_value)
                 except ValueError:
-                    self.debug("remove: '%s' not in %s", update_value, attr)
+                    self.debug(
+                        "remove: '%s' not in %s",
+                        safe_output(attr, update_value), attr)
                 else:
                     entry[attr] = entry_values
                     self.debug('remove: updated value %s', safe_output(
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to