Merge pull request #66 from moreati/when-is-a-builtin-in-like-a-door

Replace all calls to file() with open()
pull/79/head
dw 7 years ago committed by GitHub
commit 227defce9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -363,7 +363,7 @@ a large fleet of machines, or to alert the parent of unexpected state changes.
elif new_size < size: elif new_size < size:
size = 0 size = 0
fp = file(path, 'r') fp = open(path, 'r')
fp.seek(size) fp.seek(size)
channel.send(fp.read(new_size - size)) channel.send(fp.read(new_size - size))
fp.close() fp.close()

@ -21,7 +21,7 @@ def exec_command(cmd, in_data=None):
def read_path(path): def read_path(path):
return file(path, 'rb').read() return open(path, 'rb').read()
def write_path(path, s): def write_path(path, s):

@ -1127,7 +1127,7 @@ class ExternalContext(object):
# Reopen with line buffering. # Reopen with line buffering.
sys.stdout = os.fdopen(1, 'w', 1) sys.stdout = os.fdopen(1, 'w', 1)
fp = file('/dev/null') fp = open('/dev/null')
try: try:
os.dup2(fp.fileno(), 0) os.dup2(fp.fileno(), 0)
finally: finally:

@ -309,7 +309,7 @@ def run(dest, router, args, deadline=None, econtext=None):
tmp_path = tempfile.mkdtemp(prefix='mitogen_fakessh') tmp_path = tempfile.mkdtemp(prefix='mitogen_fakessh')
try: try:
ssh_path = os.path.join(tmp_path, 'ssh') ssh_path = os.path.join(tmp_path, 'ssh')
fp = file(ssh_path, 'w') fp = open(ssh_path, 'w')
try: try:
fp.write('#!%s\n' % (sys.executable,)) fp.write('#!%s\n' % (sys.executable,))
fp.write(inspect.getsource(mitogen.core)) fp.write(inspect.getsource(mitogen.core))

@ -8,7 +8,7 @@ import math
def get_sentinel_value(): def get_sentinel_value():
# Some proof we're even talking to the mitogen-test Docker image # 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): def add(x, y):

@ -26,7 +26,7 @@ class CommandLineTest(testlib.RouterMixin, testlib.TestCase):
# from the pipe, which is a valid script, and therefore exit indicating # from the pipe, which is a valid script, and therefore exit indicating
# success. # success.
fp = file("/dev/null", "r") fp = open("/dev/null", "r")
proc = subprocess.Popen(args, proc = subprocess.Popen(args,
stdin=fp, stdin=fp,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,

@ -89,7 +89,7 @@ class GetModuleViaSysModulesTest(testlib.TestCase):
import __main__ import __main__
path, src, is_pkg = self.call('__main__') path, src, is_pkg = self.call('__main__')
self.assertEquals(path, __main__.__file__) self.assertEquals(path, __main__.__file__)
self.assertEquals(src, file(path).read()) self.assertEquals(src, open(path).read())
self.assertFalse(is_pkg) self.assertFalse(is_pkg)
def test_dylib_fails(self): def test_dylib_fails(self):

Loading…
Cancel
Save