Use -Wdefault when running Python testdriver (#22727)
This enables Python's -Wdefault
when running the testsuite driver, to catch deprecated code.
This has caught several string literals using invalid escape sequences, which I had mostly fixed in !9669 (closed) but forgot about one.
In runtests.py
I had to change open(arg)
to io.open(arg)
, otherwise mypy fails. This is strange, since in Python 3 open
and io.open
are supposed to be the same. This seems to be a bug that has been fixed; if I run mypy locally, it does not give this error (it gives different failures, but that can be fixed later).
I removed sys.stdout = os.fdopen(sys.__stdout__.fileno(), "w")
. I wrote that code originally when porting to Python 3 for symmetry with Python 2 but I believe it was never needed.
Fixes #22727 (closed).