This replaces use of file() with open() which is python 3 compatible, and also adds it to our python 3 support test suite.
(imported from commit 050536bb4ac7384d5b98d5cf6cb7430b2b00dbd5)