Catch only UnicodeError for string decode failure.

The default exception (which we use) for decode
failures is UnicodeError or a subclass of it.

This fixes a unittest that forces RuntimeError. We
shouldn't use blanket except blocks either way.
This commit is contained in:
behackett 2011-05-06 10:36:13 -07:00
parent afe6c518c3
commit 8021c75932

View File

@ -87,7 +87,7 @@ def _make_c_string(string, check_null=False):
try:
string.decode("utf-8")
return string + "\x00"
except:
except UnicodeError:
raise InvalidStringData("strings in documents must be valid "
"UTF-8: %r" % string)