URL: https://github.com/SSSD/sssd/pull/157
Author: lslebodn
 Title: #157: intg: Fix python3 issues
Action: opened

PR body:
"""
Mostly string/bytes related issues.

It looks like my comments to the integration tests
were lost as part of review or due to rebases.
"""

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/157/head:pr157
git checkout pr157
From 2af60484ad5c972522256dc406ef8c9246135137 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lsleb...@redhat.com>
Date: Thu, 16 Feb 2017 10:07:33 +0100
Subject: [PATCH] intg: Fix python3 issues

Mostly string/bytes related issues.
---
 src/tests/intg/files_ops.py   |  1 +
 src/tests/intg/sssd_group.py  |  6 ++++--
 src/tests/intg/sssd_passwd.py | 11 ++++++-----
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/tests/intg/files_ops.py b/src/tests/intg/files_ops.py
index 65b3e5e..b7ef89d 100644
--- a/src/tests/intg/files_ops.py
+++ b/src/tests/intg/files_ops.py
@@ -77,6 +77,7 @@ def _read_contents(self):
 
     def _write_contents(self, contents):
         tmp_file = tempfile.NamedTemporaryFile(dir=self.tmp_dir, delete=False)
+        contents = [line.encode('utf-8') for line in contents]
         tmp_file.writelines(contents)
         tmp_file.flush()
 
diff --git a/src/tests/intg/sssd_group.py b/src/tests/intg/sssd_group.py
index a9cfb32..ab873a7 100644
--- a/src/tests/intg/sssd_group.py
+++ b/src/tests/intg/sssd_group.py
@@ -46,6 +46,7 @@ def getgrnam_r(name, result_p, buffer_p, buflen):
 
     errno = POINTER(c_int)(c_int(0))
 
+    name = name.encode('utf-8')
     res = func(c_char_p(name), result_p, buffer_p, buflen, errno)
 
     return (int(res), int(errno[0]), result_p)
@@ -56,13 +57,14 @@ def set_group_dict(res, result_p):
         return dict()
 
     group_dict = dict()
-    group_dict['name'] = result_p[0].gr_name
+    group_dict['name'] = result_p[0].gr_name.decode('utf-8')
     group_dict['gid'] = result_p[0].gr_gid
     group_dict['mem'] = list()
 
     i = 0
     while result_p[0].gr_mem[i] != None:
-        group_dict['mem'].append(result_p[0].gr_mem[i])
+        grp_name = result_p[0].gr_mem[i].decode('utf-8')
+        group_dict['mem'].append(grp_name)
         i = i+1
 
     return group_dict
diff --git a/src/tests/intg/sssd_passwd.py b/src/tests/intg/sssd_passwd.py
index 8b741ea..f285b49 100644
--- a/src/tests/intg/sssd_passwd.py
+++ b/src/tests/intg/sssd_passwd.py
@@ -38,13 +38,13 @@ def set_user_dict(res, result_p):
         return dict()
 
     user_dict = dict()
-    user_dict['name'] = result_p[0].pw_name
-    user_dict['passwd'] = result_p[0].pw_passwd
+    user_dict['name'] = result_p[0].pw_name.decode('utf-8')
+    user_dict['passwd'] = result_p[0].pw_passwd.decode('utf-8')
     user_dict['uid'] = result_p[0].pw_uid
     user_dict['gid'] = result_p[0].pw_gid
-    user_dict['gecos'] = result_p[0].pw_gecos
-    user_dict['dir'] = result_p[0].pw_dir
-    user_dict['shell'] = result_p[0].pw_shell
+    user_dict['gecos'] = result_p[0].pw_gecos.decode('utf-8')
+    user_dict['dir'] = result_p[0].pw_dir.decode('utf-8')
+    user_dict['shell'] = result_p[0].pw_shell.decode('utf-8')
     return user_dict
 
 
@@ -64,6 +64,7 @@ def getpwnam_r(name, result_p, buffer_p, buflen):
 
     errno = POINTER(c_int)(c_int(0))
 
+    name = name.encode('utf-8')
     res = func(c_char_p(name), result_p, buffer_p, buflen, errno)
 
     return (int(res), int(errno[0]), result_p)
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org

Reply via email to