aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2007-03-30 22:38:08 +0200
committerOlivier Tilloy <olivier@tilloy.net>2007-03-30 22:38:08 +0200
commit5b9561b2f53982f76990ce63d5f44271ebc3923e (patch)
treeee3e4d7cd6d1f0f3dfcc3c74ee510afd200885ab
parent59de8016bf0ccd69f7eb4059b052acead79eb3f2 (diff)
downloadpyexiv2-5b9561b2f53982f76990ce63d5f44271ebc3923e.tar.gz
Changed the type of exception raised when trying to get a value corresponding to an invalid key (TypeError, to comply with http://docs.python.org/ref/sequence-types.html).
-rw-r--r--src/libpyexiv2.cpp2
-rw-r--r--src/pyexiv2.py11
2 files changed, 7 insertions, 6 deletions
diff --git a/src/libpyexiv2.cpp b/src/libpyexiv2.cpp
index bba5ef9..729bf02 100644
--- a/src/libpyexiv2.cpp
+++ b/src/libpyexiv2.cpp
@@ -420,7 +420,7 @@ namespace LibPyExiv2
break;
case 6:
case 7:
- PyErr_SetString(PyExc_KeyError, message);
+ PyErr_SetString(PyExc_IndexError, message);
break;
case 4:
case 5:
diff --git a/src/pyexiv2.py b/src/pyexiv2.py
index 02af79e..118b899 100644
--- a/src/pyexiv2.py
+++ b/src/pyexiv2.py
@@ -455,7 +455,6 @@ class Image(libpyexiv2.Image):
self.__setIptcTag(key, strVal, index)
def __getitem__(self, key):
- #print 'Calling __getitem__(...)'
if key.__class__ is not str:
raise TypeError('Key must be of type string')
tagFamily = key[:4]
@@ -478,10 +477,12 @@ class Image(libpyexiv2.Image):
self.__iptcTagsDict[key] = value
return value
else:
- raise IndexError("'" + key + "': invalid tag identifier")
+ # This is exiv2's standard error message, all futures changes on
+ # exiv2's side should be reflected here.
+ # As a future development, consider i18n for error messages.
+ raise IndexError("Invalid key `" + key + "'")
def __setitem__(self, key, value):
- #print 'Calling __setitem__(...)'
if key.__class__ is not str:
raise TypeError('Key must be of type string')
tagFamily = key[:4]
@@ -538,7 +539,7 @@ class Image(libpyexiv2.Image):
else:
del self.__iptcTagsDict[key]
else:
- raise IndexError("'" + key + "': invalid tag identifier")
+ raise IndexError("Invalid key `" + key + "'")
def __delitem__(self, key):
#print 'Calling __delitem__(...)'
@@ -557,7 +558,7 @@ class Image(libpyexiv2.Image):
self.__deleteIptcTag(key, 0)
del self.__iptcTagsDict[key]
else:
- raise IndexError("'" + key + "': invalid tag identifier")
+ raise IndexError("Invalid key `" + key + "'")
def cacheAllExifTags(self):
for key in self.exifKeys():