Ticket #12642: 0001-Python-binding-call-Socket.send-with-non-unicode-str.patch

File 0001-Python-binding-call-Socket.send-with-non-unicode-str.patch, 1.3 KB (added by angela.schmid@…, 8 years ago)
  • mythtv/bindings/python/MythTV/connections.py

    From e2789bdbeb016c7aa537d9ecf3175a2b3641c456 Mon Sep 17 00:00:00 2001
    From: angelaschmid <angela.schmid@wolke7.net>
    Date: Sun, 7 Feb 2016 03:53:12 +0100
    Subject: [PATCH] Python binding - call Socket.send with non-unicode string
    
    Socket.send takes a string (not unicode).
    When Socket.send is called with an unicode string it tries to convert it with the ascii codec converter, resulting in an UnicodeEncodeError.
    
    Before calling Socket.send the data has to be converted to a non-unicode string (UTF-8 encoded).
    ---
     mythtv/bindings/python/MythTV/connections.py | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/mythtv/bindings/python/MythTV/connections.py b/mythtv/bindings/python/MythTV/connections.py
    index 5d37ba5..9cc48a4 100644
    a b class BEConnection( object ): 
    292292            # lock socket access
    293293            with self._socklock:
    294294                # send command string
    295                 self.socket.sendheader(data)
     295                self.socket.sendheader(data.encode("utf-8"))
    296296                # wait timeout for data to be received on the socket
    297297                t = time()
    298298                timeout = (deadline-t) if (deadline-t>0) else 0.0