From 221ce5a2680c1a91b7b87a36d73be5c0ad7e5ddb Mon Sep 17 00:00:00 2001
From: Arthur de Jong <arthur@arthurdejong.org>
Date: Mon, 2 Sep 2019 23:32:30 +0200
Subject: Add Python 3 support

This ensures that both pynslcd and the command-line utilities work with
Python3 as interpreter and runs some tests with all installed Python
interpreters.

This drops support for Python 2.6 and extends 5a84be2 to perform more
testing with Python 3.
---
 utils/nslcd.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'utils/nslcd.py')

diff --git a/utils/nslcd.py b/utils/nslcd.py
index bb720a3..82e5bbb 100644
--- a/utils/nslcd.py
+++ b/utils/nslcd.py
@@ -2,7 +2,7 @@
 
 # nslcd.py - functions for doing nslcd requests
 #
-# Copyright (C) 2013-2017 Arthur de Jong
+# Copyright (C) 2013-2019 Arthur de Jong
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -55,12 +55,13 @@ class NslcdClient(object):
 
     def write_bytes(self, value):
         self.write_int32(len(value))
-        self.write(value)
+        if value:
+            self.write(value)
 
     def write_string(self, value):
         if sys.version_info[0] >= 3:
             value = value.encode('utf-8')
-        self.write_bytes(value.encode('utf-8'))
+        self.write_bytes(value)
 
     def write_ether(self, value):
         value = struct.pack('BBBBBB', *(int(x, 16) for x in value.split(':')))
-- 
cgit v1.2.3