aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pyexiv2/xmp.py2
-rw-r--r--test/xmp.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/pyexiv2/xmp.py b/src/pyexiv2/xmp.py
index 2b3149e..76e0df2 100644
--- a/src/pyexiv2/xmp.py
+++ b/src/pyexiv2/xmp.py
@@ -225,6 +225,8 @@ class XmpTag(object):
stype = stype[17:]
self.raw_value = map(lambda x: self._convert_to_string(x, stype), value)
elif type == 'LangAlt':
+ if isinstance(value, basestring):
+ value = {'x-default': value}
if not isinstance(value, dict):
raise TypeError('Expecting a dictionary mapping language codes to values')
raw_value = {}
diff --git a/test/xmp.py b/test/xmp.py
index 294cdc2..6183277 100644
--- a/test/xmp.py
+++ b/test/xmp.py
@@ -374,7 +374,13 @@ class TestXmpTag(unittest.TestCase):
tag = XmpTag('Xmp.dc.description')
self.failUnlessEqual(tag.type, 'Lang Alt')
self.failUnlessRaises(TypeError, tag._set_value, None)
- self.failUnlessRaises(TypeError, tag._set_value, 'bleh')
+ self.failUnlessRaises(TypeError, tag._set_value, ['bleh'])
+
+ def test_set_value_basestring_for_langalt(self):
+ tag = XmpTag('Xmp.dc.description')
+ self.failUnlessEqual(tag.type, 'Lang Alt')
+ tag.value = 'bleh'
+ self.failUnlessEqual(tag.value, {'x-default': 'bleh'})
class TestXmpNamespaces(unittest.TestCase):