aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pyexiv2/metadata.py2
-rw-r--r--test/encoding.py14
2 files changed, 11 insertions, 5 deletions
diff --git a/src/pyexiv2/metadata.py b/src/pyexiv2/metadata.py
index 8a76381..57c0263 100644
--- a/src/pyexiv2/metadata.py
+++ b/src/pyexiv2/metadata.py
@@ -60,7 +60,7 @@ class ImageMetadata(MutableMapping):
:type filename: string
"""
self.filename = filename
- if filename is not None:
+ if filename is not None and isinstance(filename, unicode):
self.filename = filename.encode(sys.getfilesystemencoding())
self.__image = None
self._keys = {'exif': None, 'iptc': None, 'xmp': None}
diff --git a/test/encoding.py b/test/encoding.py
index 9cc251f..f82d3ac 100644
--- a/test/encoding.py
+++ b/test/encoding.py
@@ -91,18 +91,24 @@ class TestEncodings(unittest.TestCase):
m.read()
os.remove(filename)
- def test_ascii_str(self):
+ def test_ascii(self):
self._test_filename('test.jpg')
- def test_ascii_unicode(self):
+ def test_latin1(self):
+ self._test_filename('tést.jpg')
+
+ def test_latin1_escaped(self):
+ self._test_filename('t\xc3\xa9st.jpg')
+
+ def test_unicode_ascii(self):
if self.encoding is not None:
self._test_filename(u'test.jpg')
- def test_nonascii_unicode(self):
+ def test_unicode_latin1(self):
if self.encoding is not None:
self._test_filename(u'tést.jpg')
- def test_nonascii_unicode_escaped(self):
+ def test_unicode_latin1_escaped(self):
if self.encoding is not None:
self._test_filename(u't\xe9st.jpg')