mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Add weakref support to array.array and file objects.
This commit is contained in:
parent
691d80532b
commit
cb87bc8e7e
5 changed files with 38 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue