Unset PYTHONWARNINGS envvar before running subprocess tests.

The extra warnings in the subprocesses were causing test failures.

Closes gh-5218
Explicitly close file in get_encoding
Only pop PYTHONWARNINGS if its there.
Merge pull request #5222 from takluyver/i5218

Unset PYTHONWARNINGS envvar before running subprocess tests.