[pitivi] preset: Make sure the preset names are utf-8 strings.
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] preset: Make sure the preset names are utf-8 strings.
- Date: Tue, 13 Nov 2012 04:31:48 +0000 (UTC)
commit 9c75d912a4cd48f9cfa9e29a012f2903c9c83b1b
Author: Alex BÄluÈ <alexandru balut gmail com>
Date: Sun Nov 11 23:14:35 2012 +0100
preset: Make sure the preset names are utf-8 strings.
This fixes a bug which manifests when the preset with non-ASCII chars in the name is saved.
pitivi/preset.py | 3 +++
tests/test_preset.py | 5 +++++
2 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/preset.py b/pitivi/preset.py
index 602de9a..d9e9bff 100644
--- a/pitivi/preset.py
+++ b/pitivi/preset.py
@@ -128,6 +128,9 @@ class PresetManager(object):
@param values: The values of the new preset.
@type values: dict
"""
+ if type(name) == unicode:
+ # We need utf-8 string objects, not unicode objects!
+ name = name.encode("utf-8")
if self.hasPreset(name):
raise DuplicatePresetNameException(name)
self.presets[name] = values
diff --git a/tests/test_preset.py b/tests/test_preset.py
index f6b052a..5742d97 100644
--- a/tests/test_preset.py
+++ b/tests/test_preset.py
@@ -101,6 +101,11 @@ class TestPresetBasics(TestCase):
self.manager.addPreset('x', {})
self.assertRaises(DuplicatePresetNameException, self.manager.addPreset, 'x', {})
+ def testAddPresetWithNonAsciiName(self):
+ unicode_name = u"ããããããããã"
+ self.manager.addPreset(unicode_name, {})
+ self.assertTrue(unicode_name.encode("utf-8") in self.manager.getPresetNames())
+
def testRenamePreset(self):
self.manager.addPreset('preseT onE', {'name1': '1A'})
self.manager.addPreset('Preset Two', {'name1': '2A'})
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]