Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#12642 closed Patch - Bug Fix (fixed)

Python binding socket UnicodeEncodeError

Reported by: angela.schmid@… Owned by: Raymond Wagner
Priority: minor Milestone: 0.28
Component: Bindings - Python Version: 0.28-beta
Severity: medium Keywords: python binding mythproto socket send
Cc: Ticket locked: no

Description

When using Lossless Cut, i receive the following python error when the downloaded screenshot filename contains umlaut characters:

Traceback (most recent call last):
  File "/usr/share/lossless_cut/lossless_cut.py", line 1831, in <module>
    LOSSLESS_CUT.cut_video_file()
  File "/usr/share/lossless_cut/lossless_cut.py", line 513, in cut_video_file
    self._lossless_cut()
  File "/usr/share/lossless_cut/lossless_cut.py", line 1335, in _lossless_cut
    self.mythtvinterface.add_to_mythvideo()
  File "/usr/share/lossless_cut/importcode/mythtvinterface.py", line 1364, in add_to_mythvideo
    self.vid.importMetadata(self.metadata)
  File "/usr/local/lib/python2.7/dist-packages/MythTV/dataheap.py", line 1074, in importMetadata
    getattr(self, image.type).downloadFrom(image.url)
  File "/usr/local/lib/python2.7/dist-packages/MythTV/dataheap.py", line 104, in downloadFrom
    be.downloadTo(url, self.imagetype, self)
  File "/usr/local/lib/python2.7/dist-packages/MythTV/mythproto.py", line 726, in downloadTo
    'DOWNLOAD_FILE', url, storagegroup, filename))).\
  File "/usr/local/lib/python2.7/dist-packages/MythTV/mythproto.py", line 155, in backendCommand
    return self._conn.command.backendCommand(data)
  File "/usr/local/lib/python2.7/dist-packages/MythTV/connections.py", line 295, in backendCommand
    self.socket.sendheader(data)
  File "/usr/local/lib/python2.7/dist-packages/MythTV/utility/other.py", line 392, in sendheader
    self.send(data, flags)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 109: ordinal not in range(128)

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

Attachments (1)

0001-Python-binding-call-Socket.send-with-non-unicode-str.patch (1.3 KB) - added by angela.schmid@… 8 years ago.

Download all attachments as: .zip

Change History (3)

Changed 8 years ago by angela.schmid@…

comment:1 Changed 8 years ago by angelaschmid <angela.schmid@…>

Resolution: fixed
Status: newclosed

In e20bd8bf8e274274f4fb89420905015f57233e0c/mythtv:

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

Fixes #12529
Fixes #12642

comment:2 Changed 8 years ago by Karl Egly

Milestone: unknown0.28
Note: See TracTickets for help on using tickets.