Bugfix: parts(), use unicode rather than a str for the exception message

exc can contain unicode characters which raises a UnicodeEncodeError
when formatting the string.