The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/58

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Sergio Schvezov <sergio.schve...@canonical.com>
From 90810294587ba638a4f67524d524c6b2f6695eb8 Mon Sep 17 00:00:00 2001
From: Sergio Schvezov <sergio.schve...@canonical.com>
Date: Wed, 3 Feb 2016 14:32:23 -0300
Subject: [PATCH] Support python 3.4+

Signed-off-by: Sergio Schvezov <sergio.schve...@canonical.com>
---
 pylxd/connection.py            | 16 ++++++++++++----
 pylxd/tests/test_connection.py |  9 +++++++--
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/pylxd/connection.py b/pylxd/connection.py
index 74ce925..2fb6286 100644
--- a/pylxd/connection.py
+++ b/pylxd/connection.py
@@ -17,6 +17,7 @@
 import copy
 import json
 import os
+import six
 import socket
 import ssl
 import threading
@@ -49,9 +50,13 @@ class UnixHTTPConnection(http_client.HTTPConnection):
 
     def __init__(self, path, host='localhost', port=None, strict=None,
                  timeout=None):
-        http_client.HTTPConnection.__init__(self, host, port=port,
-                                            strict=strict,
-                                            timeout=timeout)
+        if six.PY2:
+            http_client.HTTPConnection.__init__(self, host, port=port,
+                                               strict=strict,
+                                                timeout=timeout)
+        else:
+            http_client.HTTPConnection.__init__(self, host, port=port,
+                                                timeout=timeout)
 
         self.path = path
 
@@ -152,7 +157,10 @@ def _request(self, *args, **kwargs):
         status = response.status
         raw_body = response.read()
         try:
-            body = json.loads(raw_body)
+            if six.PY2:
+                body = json.loads(raw_body)
+            else:
+                body = json.loads(raw_body.decode())
         except ValueError:
             body = None
 
diff --git a/pylxd/tests/test_connection.py b/pylxd/tests/test_connection.py
index dcffa30..f15ae7f 100644
--- a/pylxd/tests/test_connection.py
+++ b/pylxd/tests/test_connection.py
@@ -15,6 +15,7 @@
 from ddt import ddt
 import inspect
 import mock
+import six
 from six.moves import cStringIO
 from six.moves import http_client
 import socket
@@ -32,8 +33,12 @@ class LXDInitConnectionTest(unittest.TestCase):
     @mock.patch.object(http_client.HTTPConnection, '__init__')
     def test_http_connection(self, mc, ms):
         conn = connection.UnixHTTPConnection('/', 'host', 1234)
-        mc.assert_called_once_with(
-            conn, 'host', port=1234, strict=None, timeout=None)
+        if six.PY2:
+            mc.assert_called_once_with(
+                conn, 'host', port=1234, strict=None, timeout=None)
+        else:
+            mc.assert_called_once_with(
+                conn, 'host', port=1234, timeout=None)
         conn.connect()
         ms.assert_called_once_with(socket.AF_UNIX, socket.SOCK_STREAM)
         ms.return_value.connect.assert_called_once_with('/')
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to