Properly catch and decode unicode strings in module _log_invocation()

Fixes #7084