Add weakref support to array.array and file objects.
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 0f3e07f..d03618d 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -5,6 +5,7 @@
 
 import unittest
 from test import test_support
+from weakref import proxy
 import array, cStringIO, math
 
 tests = [] # list to accumulate all tests
@@ -614,6 +615,13 @@
         b = buffer(a)
         self.assertEqual(b[0], a.tostring()[0])
 
+    def test_weakref(self):
+        s = array.array(self.typecode, self.example)
+        p = proxy(s)
+        self.assertEqual(p.tostring(), s.tostring())
+        s = None
+        self.assertRaises(ReferenceError, len, p)
+
     def test_bug_782369(self):
         import sys
         if hasattr(sys, "getrefcount"):
@@ -624,6 +632,8 @@
                 b = array.array('B', range(64))
             self.assertEqual(rc, sys.getrefcount(10))
 
+
+
 class StringTest(BaseTest):
 
     def test_setitem(self):
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index 22db9a2..ddd0471 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -1,10 +1,25 @@
 import sys
 import os
 from array import array
+from weakref import proxy
 
 from test.test_support import verify, TESTFN, TestFailed
 from UserList import UserList
 
+# verify weak references
+f = file(TESTFN, 'w')
+p = proxy(f)
+p.write('teststring')
+verify(f.tell(), p.tell())
+f.close()
+f = None
+try:
+    p.tell()
+except ReferenceError:
+    pass
+else:
+    raise TestFailed('file proxy still exists when the file is gone')
+
 # verify expected attributes exist
 f = file(TESTFN, 'w')
 softspace = f.softspace