Recover from codec error when en/de-coding instance

If UnicodeError is raised during converting instance
to unicode/bytes then use result of 'repr' function
as unicode/bytes representation of instance.
Don't break formatting if code context is uknown
Recover when value of variable raises error

This happens e.g. for BeautifulSoup because its string
representation needs walk through the element's tree.