Marc-Andre Lemburg added the comment: Nick, I think you've missed the "undefined" encoding that we've had for this ever since Unicode was added to Python.
You put the needed code into your sitecustomize.py file and Python2 will then behave just like Python3, i.e. raise an exception instead of coercing to Unicode: sitecustomize.py: import sys sys.setdefaultencoding('undefined') There's no need to hack this into site.py or to make sys.setdefaultencoding() available outside sitecustomize.py. If you want an OS environ switch, you can put the necessary logic into sitecustomize.py as well. ---------- nosy: +lemburg _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28403> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com