[Pkg-mpd-commits] [python-mpd] 253/262: fix newline in protocol on windows python3x

Simon McVittie smcv at debian.org
Sun May 22 18:16:55 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch upstream
in repository python-mpd.

commit 1e969b69c15e4386a2a550e069951719435eb252
Author: Jörg Thalheim <joerg at higgsboson.tk>
Date:   Thu Dec 10 23:12:19 2015 +0100

    fix newline in protocol on windows python3x
    
    fixes #62
---
 doc/changes.rst |  4 ++++
 mpd.py          | 14 ++++++++++----
 test.py         |  4 ++--
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/doc/changes.rst b/doc/changes.rst
index ce9570b..32cd6e3 100644
--- a/doc/changes.rst
+++ b/doc/changes.rst
@@ -1,6 +1,10 @@
 python-mpd2 Changes List
 ========================
 
+Changes in v0.5.x
+-----------------
+* fix sended newlines on windows systems
+
 Changes in v0.5.4
 -----------------
 * support for listfiles, rangeid, addtagid, cleartagid, mount, umount, listmounts, listneighbors
diff --git a/mpd.py b/mpd.py
index 0c6fc01..f4c38a5 100644
--- a/mpd.py
+++ b/mpd.py
@@ -538,10 +538,16 @@ class MPDClient(object):
             self._rfile = self._sock.makefile("r")
             self._wfile = self._sock.makefile("w")
         else:
-            # Force UTF-8 encoding, since this is dependant from the LC_CTYPE
-            # locale.
-            self._rfile = self._sock.makefile("r", encoding="utf-8")
-            self._wfile = self._sock.makefile("w", encoding="utf-8")
+            # - Force UTF-8 encoding, since this is dependant from the LC_CTYPE
+            #   locale.
+            # - by setting newline explicit, we force to send '\n' also on
+            #   windows
+            self._rfile = self._sock.makefile("r",
+                                              encoding="utf-8",
+                                              newline="\n")
+            self._wfile = self._sock.makefile("w",
+                                              encoding="utf-8",
+                                              newline="\n")
 
         try:
             self._hello()
diff --git a/test.py b/test.py
index 59aa22a..ee588f0 100755
--- a/test.py
+++ b/test.py
@@ -342,8 +342,8 @@ class TestMPDClient(unittest.TestCase):
         # Force the reconnection to refill the mock
         self.client.disconnect()
         self.client.connect(TEST_MPD_HOST, TEST_MPD_PORT)
-        self.assertEqual([mock.call('r', encoding="utf-8"),
-                          mock.call('w', encoding="utf-8")],
+        self.assertEqual([mock.call('r', encoding="utf-8", newline="\n"),
+                          mock.call('w', encoding="utf-8", newline="\n")],
                          # We are onlyy interested into the 2 first entries,
                          # otherwise we get all the readline() & co...
                          self.client._sock.makefile.call_args_list[0:2])

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mpd/python-mpd.git



More information about the Pkg-mpd-commits mailing list