Traceback when copying or creating a theme with background image on Windows

Bug #1390917 reported by Tomas Groth
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenLP
Fix Released
Medium
Tomas Groth

Bug Description

Reproducable on Windows with the 2.1.1 beta

When copying a theme with background image I get this traceback:
Traceback (most recent call last):
  File "C:\Users\tgc\OpenLP\trunk\openlp\core\ui\thememanager.py", line 298, in on_copy_theme
    self.clone_theme_data(theme_data, new_theme_name)
  File "C:\Users\tgc\OpenLP\trunk\openlp\core\ui\thememanager.py", line 314, in clone_theme_data
    self.save_theme(theme_data, save_from, save_to)
  File "C:\Users\tgc\OpenLP\trunk\openlp\core\ui\thememanager.py", line 632, in save_theme
    self._write_theme(theme, image_from, image_to)
  File "C:\Users\tgc\OpenLP\trunk\openlp\core\ui\thememanager.py", line 666, in _write_theme
    shutil.copyfile(str(image_from).encode(encoding), str(image_to).encode(encoding))
  File "c:\python33\lib\shutil.py", line 92, in copyfile
    if _samefile(src, dst):
  File "c:\python33\lib\shutil.py", line 77, in _samefile
    return os.path.samefile(src, dst)
  File "c:\python33\lib\ntpath.py", line 603, in samefile
    return _getfinalpathname(f1) == _getfinalpathname(f2)
TypeError: must be str, not bytes

When createing a new theme with background image I get this traceback:
Traceback (most recent call last):
  File "C:\Users\tgc\OpenLP\trunk\openlp\core\ui\themeform.py", line 533, in accept
    self.theme_manager.save_theme(self.theme, save_from, save_to)
  File "C:\Users\tgc\OpenLP\trunk\openlp\core\ui\thememanager.py", line 632, in save_theme
    self._write_theme(theme, image_from, image_to)
  File "C:\Users\tgc\OpenLP\trunk\openlp\core\ui\thememanager.py", line 666, in _write_theme
    shutil.copyfile(str(image_from).encode(encoding), str(image_to).encode(encoding))
  File "c:\python33\lib\shutil.py", line 92, in copyfile
    if _samefile(src, dst):
  File "c:\python33\lib\shutil.py", line 77, in _samefile
    return os.path.samefile(src, dst)
  File "c:\python33\lib\ntpath.py", line 603, in samefile
    return _getfinalpathname(f1) == _getfinalpathname(f2)
TypeError: must be str, not bytes

Problem is in same method: _write_theme
Most likely shutil.copyfile cannot handle bytes input on windows. This is not an issue on linux.

Related branches

Tomas Groth (tomasgroth)
Changed in openlp:
assignee: nobody → Tomas Groth (tomasgroth)
status: New → In Progress
description: updated
Phill (phill-ridout)
Changed in openlp:
importance: Undecided → Medium
Tim Bentley (trb143)
Changed in openlp:
milestone: none → 2.1.2
status: In Progress → Fix Committed
Tim Bentley (trb143)
Changed in openlp:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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