This works around the fact that some libraries might monkey patch the file object, so the previous approach of marshal.dump(co, file) breaks because file is not a built-in file object anymore. Fix #3503