On Sat, Sep 12, 2020 at 5:29 AM Stephen J. Turnbull <turnbull.stephen.fw@u.tsukuba.ac.jp> wrote:
See Naoki Inada's post for why this might be a good idea even though
it's a three-line function.  It's not open and shut (for one thing, on
most modern systems the system default encoding is already UTF-8),

Actually that fact is the most compelling reason to do this -- since many (most) development systems use UTF-* by default then if you leave the encoding out, your code will work most of the time, pass tests, pass test on the CI, etc, and then barf when it's run on an unusual system.

I have to say that I"m not at all sure that I've remembered to set the encoding in my code that reads/writes JSON from files. Time to go check. In fact, I'm getting bytes/str errors in JSON related parts of code I'm porting to py3 right now. This is probably related.

-CHB



--
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython