Anna Ravenscroft identified many occurrences of "file" used to open a file

in the stdlib and changed each of them to use "open" instead.  At this
time there are no other known occurrences that can be safely changed (in
Lib and all subdirectories thereof).
This commit is contained in:
Alex Martelli 2006-08-24 02:58:11 +00:00
parent b5d47efe92
commit 01c77c6628
17 changed files with 53 additions and 53 deletions

View file

@ -16,8 +16,8 @@ class IntTestCase(unittest.TestCase):
s = marshal.dumps(expected)
got = marshal.loads(s)
self.assertEqual(expected, got)
marshal.dump(expected, file(test_support.TESTFN, "wb"))
got = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(expected, open(test_support.TESTFN, "wb"))
got = marshal.load( open(test_support.TESTFN, "rb"))
self.assertEqual(expected, got)
n = n >> 1
os.unlink(test_support.TESTFN)
@ -51,8 +51,8 @@ class IntTestCase(unittest.TestCase):
new = marshal.loads(marshal.dumps(b))
self.assertEqual(b, new)
self.assertEqual(type(b), type(new))
marshal.dump(b, file(test_support.TESTFN, "wb"))
new = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(b, open(test_support.TESTFN, "wb"))
new = marshal.load(open(test_support.TESTFN, "rb"))
self.assertEqual(b, new)
self.assertEqual(type(b), type(new))
@ -67,8 +67,8 @@ class FloatTestCase(unittest.TestCase):
s = marshal.dumps(f)
got = marshal.loads(s)
self.assertEqual(f, got)
marshal.dump(f, file(test_support.TESTFN, "wb"))
got = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(f, open(test_support.TESTFN, "wb"))
got = marshal.load(open(test_support.TESTFN, "rb"))
self.assertEqual(f, got)
n /= 123.4567
@ -94,12 +94,12 @@ class FloatTestCase(unittest.TestCase):
got = marshal.loads(s)
self.assertEqual(f, got)
marshal.dump(f, file(test_support.TESTFN, "wb"))
got = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(f, open(test_support.TESTFN, "wb"))
got = marshal.load(open(test_support.TESTFN, "rb"))
self.assertEqual(f, got)
marshal.dump(f, file(test_support.TESTFN, "wb"), 1)
got = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(f, open(test_support.TESTFN, "wb"), 1)
got = marshal.load(open(test_support.TESTFN, "rb"))
self.assertEqual(f, got)
n *= 123.4567
os.unlink(test_support.TESTFN)
@ -110,8 +110,8 @@ class StringTestCase(unittest.TestCase):
new = marshal.loads(marshal.dumps(s))
self.assertEqual(s, new)
self.assertEqual(type(s), type(new))
marshal.dump(s, file(test_support.TESTFN, "wb"))
new = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(s, open(test_support.TESTFN, "wb"))
new = marshal.load(open(test_support.TESTFN, "rb"))
self.assertEqual(s, new)
self.assertEqual(type(s), type(new))
os.unlink(test_support.TESTFN)
@ -121,8 +121,8 @@ class StringTestCase(unittest.TestCase):
new = marshal.loads(marshal.dumps(s))
self.assertEqual(s, new)
self.assertEqual(type(s), type(new))
marshal.dump(s, file(test_support.TESTFN, "wb"))
new = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(s, open(test_support.TESTFN, "wb"))
new = marshal.load(open(test_support.TESTFN, "rb"))
self.assertEqual(s, new)
self.assertEqual(type(s), type(new))
os.unlink(test_support.TESTFN)
@ -132,8 +132,8 @@ class StringTestCase(unittest.TestCase):
b = buffer(s)
new = marshal.loads(marshal.dumps(b))
self.assertEqual(s, new)
marshal.dump(b, file(test_support.TESTFN, "wb"))
new = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(b, open(test_support.TESTFN, "wb"))
new = marshal.load(open(test_support.TESTFN, "rb"))
self.assertEqual(s, new)
os.unlink(test_support.TESTFN)
@ -161,8 +161,8 @@ class ContainerTestCase(unittest.TestCase):
def test_dict(self):
new = marshal.loads(marshal.dumps(self.d))
self.assertEqual(self.d, new)
marshal.dump(self.d, file(test_support.TESTFN, "wb"))
new = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(self.d, open(test_support.TESTFN, "wb"))
new = marshal.load(open(test_support.TESTFN, "rb"))
self.assertEqual(self.d, new)
os.unlink(test_support.TESTFN)
@ -170,8 +170,8 @@ class ContainerTestCase(unittest.TestCase):
lst = self.d.items()
new = marshal.loads(marshal.dumps(lst))
self.assertEqual(lst, new)
marshal.dump(lst, file(test_support.TESTFN, "wb"))
new = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(lst, open(test_support.TESTFN, "wb"))
new = marshal.load(open(test_support.TESTFN, "rb"))
self.assertEqual(lst, new)
os.unlink(test_support.TESTFN)
@ -179,8 +179,8 @@ class ContainerTestCase(unittest.TestCase):
t = tuple(self.d.keys())
new = marshal.loads(marshal.dumps(t))
self.assertEqual(t, new)
marshal.dump(t, file(test_support.TESTFN, "wb"))
new = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(t, open(test_support.TESTFN, "wb"))
new = marshal.load(open(test_support.TESTFN, "rb"))
self.assertEqual(t, new)
os.unlink(test_support.TESTFN)
@ -191,8 +191,8 @@ class ContainerTestCase(unittest.TestCase):
self.assertEqual(t, new)
self.assert_(isinstance(new, constructor))
self.assertNotEqual(id(t), id(new))
marshal.dump(t, file(test_support.TESTFN, "wb"))
new = marshal.load(file(test_support.TESTFN, "rb"))
marshal.dump(t, open(test_support.TESTFN, "wb"))
new = marshal.load(open(test_support.TESTFN, "rb"))
self.assertEqual(t, new)
os.unlink(test_support.TESTFN)