aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-10-26 10:09:42 +0100
committerOlivier Tilloy <olivier@fluendo.com>2009-10-26 10:09:42 +0100
commite34793b91ab8744371da9d06c2a763eb7c04d75d (patch)
tree023d704f425d9196646e95ae101ea344240102cd
parentaebda0758a0fa98462ecc92e5de6b2c17d3ad8f0 (diff)
downloadpyexiv2-e34793b91ab8744371da9d06c2a763eb7c04d75d.tar.gz
Do not allow setting the values of an IPTC tag to something else than a list or a tuple.
-rw-r--r--src/pyexiv2/iptc.py2
-rw-r--r--test/iptc.py6
2 files changed, 8 insertions, 0 deletions
diff --git a/src/pyexiv2/iptc.py b/src/pyexiv2/iptc.py
index 4ba6b21..46d543f 100644
--- a/src/pyexiv2/iptc.py
+++ b/src/pyexiv2/iptc.py
@@ -81,6 +81,8 @@ class IptcTag(MetadataTag, ListenerInterface):
return self._values
def _set_values(self, new_values):
+ if not isinstance(new_values, (list, tuple)):
+ raise TypeError('Expecting a list of values')
if self.metadata is not None:
raw_values = map(self._convert_to_string, new_values)
self.metadata._set_iptc_tag_values(self.key, raw_values)
diff --git a/test/iptc.py b/test/iptc.py
index 5473090..4a8e4fe 100644
--- a/test/iptc.py
+++ b/test/iptc.py
@@ -213,6 +213,12 @@ class TestIptcTag(unittest.TestCase):
# Invalid values
self.failUnlessRaises(IptcValueError, tag._convert_to_string, None)
+ def test_set_single_value_raises(self):
+ tag = IptcTag('Iptc.Application2.City', 'City', 'City', 'Identifies ' \
+ 'city of object data origin according to guidelines ' \
+ 'established by the provider.', 'String', ['Seattle'])
+ self.failUnlessRaises(TypeError, tag._set_values, 'Barcelona')
+
def test_set_values_no_metadata(self):
tag = IptcTag('Iptc.Application2.City', 'City', 'City', 'Identifies ' \
'city of object data origin according to guidelines ' \