[Pkg-mpd-commits] [python-mpd] 124/262: Fix crash when sending unicode strings to socket

Simon McVittie smcv at debian.org
Sun May 22 18:16:35 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 c5cefdbc617a041a7da61ed8139c78d3ea535f05
Author: Jörg Thalheim <jthalheim at gmail.com>
Date:   Thu Mar 22 21:32:53 2012 +0100

    Fix crash when sending unicode strings to socket
    
    It's only an issue with Python 2: it would try to coerce the Unicode
    string to ASCII, which will not work unless all characters are part of ASCII.
    Overwrite str() with unicode() in python 2.x, solve this.
    Fix issue #4
---
 mpd.py  | 6 ++++++
 test.py | 6 +++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/mpd.py b/mpd.py
index 4c10037..1765771 100644
--- a/mpd.py
+++ b/mpd.py
@@ -23,6 +23,12 @@ ERROR_PREFIX = "ACK "
 SUCCESS = "OK"
 NEXT = "list_OK"
 
+try:
+    # workaround to get unicode strings in all python versions
+    str = unicode
+except NameError:
+    pass
+
 
 class MPDError(Exception):
     pass
diff --git a/test.py b/test.py
index a864df0..124e333 100755
--- a/test.py
+++ b/test.py
@@ -151,7 +151,11 @@ class TestMPDClient(unittest.TestCase):
         self.assertFalse(imple_cmds - avaible_cmds, long_desc)
 
     def test_unicode_in_command_args(self):
-        self.assertIsInstance(self.client.find("file", "☯☾☝♖✽"), list)
+        if sys.version_info < (3, 0):
+            arg = "☯☾☝♖✽".decode("utf-8")
+        else:
+            arg = "☯☾☝♖✽"
+        self.assertIsInstance(self.client.find("file",arg), list)
 
 if __name__ == '__main__':
     unittest.main()

-- 
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