diff --git a/docs/index.rst b/docs/index.rst index 36c44f82..fbe944b1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -363,7 +363,7 @@ a large fleet of machines, or to alert the parent of unexpected state changes. elif new_size < size: size = 0 - fp = file(path, 'r') + fp = open(path, 'r') fp.seek(size) channel.send(fp.read(new_size - size)) fp.close() diff --git a/mitogen/ansible/helpers.py b/mitogen/ansible/helpers.py index 4b70cde2..7dd3f3a0 100644 --- a/mitogen/ansible/helpers.py +++ b/mitogen/ansible/helpers.py @@ -21,7 +21,7 @@ def exec_command(cmd, in_data=None): def read_path(path): - return file(path, 'rb').read() + return open(path, 'rb').read() def write_path(path, s): diff --git a/mitogen/core.py b/mitogen/core.py index af8ab41f..eb1a04ad 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -1127,7 +1127,7 @@ class ExternalContext(object): # Reopen with line buffering. sys.stdout = os.fdopen(1, 'w', 1) - fp = file('/dev/null') + fp = open('/dev/null') try: os.dup2(fp.fileno(), 0) finally: diff --git a/mitogen/fakessh.py b/mitogen/fakessh.py index f7173abe..48003727 100644 --- a/mitogen/fakessh.py +++ b/mitogen/fakessh.py @@ -309,7 +309,7 @@ def run(dest, router, args, deadline=None, econtext=None): tmp_path = tempfile.mkdtemp(prefix='mitogen_fakessh') try: ssh_path = os.path.join(tmp_path, 'ssh') - fp = file(ssh_path, 'w') + fp = open(ssh_path, 'w') try: fp.write('#!%s\n' % (sys.executable,)) fp.write(inspect.getsource(mitogen.core)) diff --git a/tests/data/plain_old_module.py b/tests/data/plain_old_module.py index e09024a5..342b25a8 100755 --- a/tests/data/plain_old_module.py +++ b/tests/data/plain_old_module.py @@ -8,7 +8,7 @@ import math def get_sentinel_value(): # Some proof we're even talking to the mitogen-test Docker image - return file('/etc/sentinel').read() + return open('/etc/sentinel').read() def add(x, y): diff --git a/tests/first_stage_test.py b/tests/first_stage_test.py index 4baa024b..54d8a72b 100644 --- a/tests/first_stage_test.py +++ b/tests/first_stage_test.py @@ -26,7 +26,7 @@ class CommandLineTest(testlib.RouterMixin, testlib.TestCase): # from the pipe, which is a valid script, and therefore exit indicating # success. - fp = file("/dev/null", "r") + fp = open("/dev/null", "r") proc = subprocess.Popen(args, stdin=fp, stdout=subprocess.PIPE, diff --git a/tests/module_finder_test.py b/tests/module_finder_test.py index ef58fa06..d7182d31 100644 --- a/tests/module_finder_test.py +++ b/tests/module_finder_test.py @@ -89,7 +89,7 @@ class GetModuleViaSysModulesTest(testlib.TestCase): import __main__ path, src, is_pkg = self.call('__main__') self.assertEquals(path, __main__.__file__) - self.assertEquals(src, file(path).read()) + self.assertEquals(src, open(path).read()) self.assertFalse(is_pkg) def test_dylib_fails(self):