Fix crash when $EDITOR is non-ASCII

Catch $EDITOR being non-ASCII on Python 2 and fall back to the defaults, rather than crashing.

Also, setting unicode traits from invalid bytes now produces a useful error message, rather than a crash with a complex traceback.

Fixes #4615.