aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2012-03-15 10:29:55 +0100
committerOlivier Tilloy <olivier@tilloy.net>2012-03-15 10:29:55 +0100
commit9bc76156799faf140494e9298b41c2f4acfa0e0c (patch)
tree4db05e7c2cd119d4f2bd53ec1448fcf298c21025
parent8991499cce204188a38ffe25f1251e5a1a0965c3 (diff)
downloadpyexiv2-9bc76156799faf140494e9298b41c2f4acfa0e0c.tar.gz
Fix undefined_to_string to accept empty strings.
-rw-r--r--src/pyexiv2/utils.py4
-rw-r--r--test/utils.py4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/pyexiv2/utils.py b/src/pyexiv2/utils.py
index 0325699..95c3921 100644
--- a/src/pyexiv2/utils.py
+++ b/src/pyexiv2/utils.py
@@ -2,7 +2,7 @@
# ******************************************************************************
#
-# Copyright (C) 2006-2011 Olivier Tilloy <olivier@tilloy.net>
+# Copyright (C) 2006-2012 Olivier Tilloy <olivier@tilloy.net>
#
# This file is part of the pyexiv2 distribution.
#
@@ -148,6 +148,8 @@ def undefined_to_string(undefined):
:return: the corresponding decoded string
:rtype: string
"""
+ if undefined == '':
+ return ''
return ''.join(map(lambda x: chr(int(x)), undefined.rstrip().split(' ')))
diff --git a/test/utils.py b/test/utils.py
index 0b55254..cdff0d2 100644
--- a/test/utils.py
+++ b/test/utils.py
@@ -2,7 +2,7 @@
# ******************************************************************************
#
-# Copyright (C) 2010 Olivier Tilloy <olivier@tilloy.net>
+# Copyright (C) 2010-2012 Olivier Tilloy <olivier@tilloy.net>
#
# This file is part of the pyexiv2 distribution.
#
@@ -36,7 +36,7 @@ class TestConversions(unittest.TestCase):
def test_undefined_to_string(self):
self.assertEqual(undefined_to_string("48 50 50 49"), "0221")
self.assertEqual(undefined_to_string("48 50 50 49 "), "0221")
- self.assertRaises(ValueError, undefined_to_string, "")
+ self.assertEqual(undefined_to_string(""), "")
self.assertRaises(ValueError, undefined_to_string, "foo")
self.assertRaises(ValueError, undefined_to_string, "48 50 50 49")