libmyth-python: Issue with national characters in filename

Bug #1183466 reported by peterdv
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mythtv (Ubuntu)
New
Undecided
Unassigned

Bug Description

In MythTV/dataheap.py national characters in filename
causes an UnicodeEncodeError to be thrown in Video.open(),
in the statement:

        return ftopen('myth://Videos@{0.host}/{0.filename}'.format(self),
                    mode, False, nooverwrite, self._db)

For me the problem can be fixed by ensuring that
the filename format string is unicode:

        return ftopen(u'myth://Videos@{0.host}/{0.filename}'.format(self),
                    mode, False, nooverwrite, self._db)

The problem was actually experienced in mythvidexport.py,
from https://github.com/wagnerrp/mythtv-scripts,
as modified in commit 0c6ebb4b78dd398a9d9d329b7aeafa314f40c545 of
the fork https://github.com/spmorton/mythtv-scripts.
The system had MythTV/dataheap.py installed from the
Ubuntu repositories from the package
libmyth-python 2:0.26.0+fixes.2012

mythtv@media02:/var/log/mythtv$ /usr/share/mythtv/mythvidexport.py --chanid=1101 --starttime=1328386500
2013-05-22 17:50:59.805274 I [16429] mythvidexport.py Using recording -- Wallander: Lækken - Svensk krimi fra 2009.Brændende biler og afspærrede motorveje. Ystad rammes af en række spektakulære røverier mod pengetransport
2013-05-22 17:50:59.824353 I [16429] mythvidexport.py Attempting TV export.
2013-05-22 17:51:00.014421 I [16429] mythvidexport.py Falling back to generic export.
2013-05-22 17:51:00.026309 I [16429] mythvidexport.py Import complete
2013-05-22 17:51:00.028494 I [16429] mythvidexport.py Copying myth://Default@media02/1101_20120204211500.mpg to myth://Videos@media02/Videos/Wallander: Lækken.mpg
2013-05-22 17:51:00.051557 I [16429] mythvidexport.py Checking for duplication of -- Wallander: Lækken - Svensk krimi fra 2009.Brændende biler og afspærrede motorveje. Ystad rammes af en række spektakulære røverier mod pengetransport
Traceback (most recent call last):
Traceback (most recent call last):
  File "/usr/share/mythtv/mythvidexport.py", line 447, in <module>
    main()
  File "/usr/share/mythtv/mythvidexport.py", line 419, in main
    export = VIDEO(opts)
  File "/usr/share/mythtv/mythvidexport.py", line 75, in __init__
    self.copy()
  File "/usr/share/mythtv/mythvidexport.py", line 246, in copy
    dstfp = self.vid.open('w')
  File "/usr/lib/python2.7/dist-packages/MythTV/dataheap.py", line 931, in open
    return ftopen('myth://Videos@{0.host}/{0.filename}'.format(self),
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe6' in position 19: ordinal not in range(128)
mythtv@media02:/var/log/mythtv$ printenv LANG
en_DK.UTF-8

Starting off in:
  "Software should only work with Unicode strings internally,
   converting to a particular encoding on output."

And noting that: "When it comes to unicode filenames in python,
on Unix systems, there will only be a filesystem encoding
if you’ve set the LANG or LC_CTYPE environment variables;
if you haven’t, the default encoding is ASCII.
When opening a file for reading or writing,
you can usually just provide the Unicode string as
the filename, and it will be automatically converted
to the right encoding for you."

I ended up believing that using an unicode format string
might be the right solution.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.