Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.147.70.101
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_weakref.pyo
�
@��cc@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
eadfd��YZ
dfd��YZd�Zd�Zd	�Zd
fd��YZdfd
��YZejdd��Zdejfd��YZdefd��YZdefd��YZdefd��YZddl	mZdejfd��YZdejfd��YZdZied6Z d�Z!e"d kr�e!�ndS(!i����N(ttest_supporttCcBseZd�ZRS(cCsdS(N((tself((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytmethods(t__name__t
__module__R(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRstCallablecBseZdZd�ZRS(cCs
||_dS(N(tbar(Rtx((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt__call__sN(RRtNoneRR	(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRscCs
d�}|S(NcSsdS(N((((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytft((R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytcreate_functions	cCs
t�jS(N(RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytcreate_bound_method scCstjS(N(RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytcreate_unbound_method#stObjectcBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs
||_dS(N(targ(RR((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt__init__(scCsd|jS(Ns<Object %r>(R(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt__repr__*scCs#t|t�r|j|jkStS(N(t
isinstanceRRtNotImplemented(Rtother((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt__eq__,scCs#t|t�r|j|jkStS(N(RRRR(RR((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt__ne__0scCs
t|j�S(N(thashR(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt__hash__4s(RRRRRRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR's
				tRefCyclecBseZd�ZRS(cCs
||_dS(N(tcycle(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR8s(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR7sg����MbP?c	#s�tjd�}t���fd�}tj��dtj�}tjd�|jd|�}|j�z	dVWdt	�|j
�tj|�XWdQXdS(sR
    Ensure GC collections happen in a different thread, at a high frequency.
    t	threadingcs(x!�s#tj��tj�qWdS(N(ttimetsleeptgctcollect((tperiodtplease_stop(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR!Ds	
ittargetN(Rt
import_moduletFalset
disable_gctsystgetcheckintervaltsetcheckintervaltThreadtstarttTruetjoin(R"RR!told_intervaltt((R"R#s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytcollect_in_thread<s


	
tTestBasecBseZd�Zd�ZRS(cCs
d|_dS(Ni(tcbcalled(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytsetUpXscCs|jd7_dS(Ni(R3(Rtref((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytcallback[s(RRR4R6(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR2Vs	tReferencesTestCasecBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Ze j!d��Z"d�Z#d �Z$d!�Z%d"�Z&d#�Z'd$�Z(d%�Z)d&�Z*d'�Z+d(�Z,RS()cCsg|jt�|jt�|jt�|jt�t�}tj|�}t|�~t|�dS(N(tcheck_basic_refRR
RRtweakrefR5trepr(Rtotwr((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_basic_refas



	
cCs8|jt�|jt�|jt�|jt�dS(N(tcheck_basic_callbackRR
RR(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_basic_callbackps


cCsvt�}tj||j�}tj||j�}~|j|�d�|j|�d�|j|jdd�dS(Ns$expected reference to be invalidatedis-callback not called the right number of times(RR9R5R6tassertIsNonetassertEqualR3(RR;tref1tref2((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_multiple_callbacksvs	cCsC|d�}t�}tj||�|_tj||�}~dS(NcSs|j�dS(N(R5(tobjectR((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR6�s(RR9R5(RR6tcRB((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_multiple_selfref_callbacks�s
	cCs)t�}|jttj|dd�dS(NR6(RtassertRaisest	TypeErrorR9R5R
(RRF((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_constructor_kwargs�s	cCs�t�}d|_tj||j�}tj||j�}~d�}|jtj||�|jtj||�|jtjttjt���|j|j	d�dS(NicSs|jdS(N(R(tproxy((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytcheck�si(
RRR9RKR6RHtReferenceErrortboolRAR3(RR;RBRCRL((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_proxy_ref�s			"cCsK|�}tj|�}|j|�d�|�}|j||d�dS(Ns,weak reference to live object should be lives-<ref>() should return original object if live(R9R5tassertIsNotNonetassertIs(RtfactoryR;R5to2((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR8�s		cCsWd|_|�}tj||j�}~|j|jdd�|j|�d�dS(Niis(callback did not properly set 'cbcalled's3ref2 should be dead after deleting object reference(R3R9R5R6RAR@(RRRR;R5((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR>�s		cCs�t�}tj|�}tj|�}tj|�}|j||d�t�}tj|�}tj|�}tj|�}|j||d�|jtj|�dd�~|jtj|�dd�dS(Ns1reference object w/out callback should be re-usediswrong weak ref count for objectis4wrong weak ref count for object after deleting proxy(RR9R5RKRQRAtgetweakrefcount(RR;RBRKRC((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_ref_reuse�s"		cCsMt�}tj|�}tj|�}tj|�}|j||d�dS(Ns4proxy object w/out callback should have been re-used(RR9RKR5RQ(RR;tproxy1R5tproxy2((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_proxy_reuse�s	c
Cs�t�}|j|tj|��tj�}tj|�}|j|d�|jd�|jt|�d�|j	|d�t
j��ddg|(WdQX|jt|�d�|jt|�d�|jd|d�d|d<|j|dd�|j|dd�tj|�}tj|�}|j||�tjt
d	��}tj|�}t
j��e|j||�|j|d|d�|j|d |d �|j|dd!|dd!�WdQXdS(
Ns(proxy for empty UserList should be falseiis+proxy for non-empty UserList should be trueiis,proxy didn't support __contains__() properlyii
(Rtcheck_proxyR9RKtUserListtassertFalsetappendRAtlent
assertTrueRtcheck_py3k_warningstassertIntrange(RR;tLtptL2tp2tL3tp3((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_basic_proxy�s4	



cCsadtfd��Y}|�}|jdttj|���|jttj|��d�dS(NRcBseZd�Zd�ZRS(cSsdS(Ntstring((R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt__str__�scSsdS(Nuunicode((R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt__unicode__�s(RRRjRk(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�s	Rkuunicode(RER`tdirR9RKRAtunicode(RRtinstance((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_proxy_unicode�s	cCsHddd��Y}|�}tj|�}|jtj|�d�dS(NRcBseZd�ZRS(cSsdS(Ni
((R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt	__index__s(RRRp(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRsi
((R9RKRAtoperatortindex(RRR;Rc((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_proxy_index�s	cCs]ddd��Y}|�}tj|�}|j|dd�|d}|j|d�dS(NRcBseZd�Zd�ZRS(cSsdS(Ni*((RR((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt__floordiv__	scSsdS(Ni((RR((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt
__ifloordiv__s(RRRtRu(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRs	ii*i((R9RKRA(RRR;Rc((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_proxy_divs	
cCs|jtj�dS(N(tcheck_shared_without_callbackR9R5(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt test_shared_ref_without_callbackscCs|jtj�dS(N(RwR9RK(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt"test_shared_proxy_without_callbackscCs�td�}||d�}||d�}|j||d�~~||�}||d�}|j||d�~~||�}||�}|j||d�~~||d�}||�}|j||d�dS(Nis%both callbacks were None in the C APIs&callbacks were NULL, None in the C APIs%both callbacks were NULL in the C APIs&callbacks were None, NULL in the C API(RR
RQ(RtmakerefR;tp1Re((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRw!s cCs�t�}tj|�}|j||�|jt|�tjd�|d�|j|jdd�|dd�|j|jdd�|j	t
|�|j	t
|ddd�dS(	Nsproxy is not of callable types	twinkies!s1call through proxy not passed through to originalRsSplat.iii(RR9RKRYRQttypetCallableProxyTypeRARRHRI(RR;RB((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_callable_proxy3s	

cCs�d|_|j|jdd�d|_|j|jdd�|`|jt|d�d�d|_|j|jdd�d|_|j|jdd�|`|jt|d�d	�dS(
Nis)proxy does not reflect attribute additionis-proxy does not reflect attribute modificationtfoos(proxy does not reflect attribute removals4object does not reflect attribute addition via proxys8object does not reflect attribute modification via proxys3object does not reflect attribute removal via proxy(RRAR[thasattr(RR;RK((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRYHs$				cCsIddd��Y}|�}tj|�}|d=|j|jd�dS(NtFoocBseZdZd�ZRS(cSs
||_dS(N(tresult(Rtaccessor((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt__delitem__asN(RRR
R�R�(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�_si((R9RKRAR�(RR�tgR((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_proxy_deletion]s
	cCsHdtfd��Y}|�}|jttj|��t|��dS(NtListcBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�js(tlistRARNR9RK(RR�tlyst((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_proxy_boolhs	cCs�t�}tj|�}tj||j�}|jtj|�dd�tj|�}tj||j�}|jtj|�dd�~~~~|jtj|�dd�|jtjd�dd�dS(Nis*got wrong number of weak reference objectsiisAweak reference objects not unlinked from referent when discarded.is2got wrong number of weak reference objects for int(RR9R5R6RARTRK(RR;RBRCRVRW((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_getweakrefcountns	cCs�t�}tj||j�}tj||j�}~|jtj|�|gd�t�}tj||j�}tj||j�}~|jtj|�|gd�~|jtj|�gd�|jtjd�gd�dS(Nslist of refs does not matchslist of refs not clearedis#list of refs does not match for int(RR9R5R6RAtgetweakrefs(RR;RBRC((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_getweakrefs�s"		cCs]dtfd��Y}|d�}tj|�}|j|dd�|jd|d�dS(NtFcBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��sg@g�?g@(tfloatR9RKRA(RR�RRc((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_newstyle_number_ops�s
cs�dtfd��Y�i��fd�����fd�}y|�Wn�k
r^nX|jd�y|�Wn�k
r�nX|jd�dS(Nt
BogusErrorcBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��scs�|=dS(N((tk(tdata(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytremove�scs)d�}d�tj|��<��dS(NcSsdS(N(((((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt<lambda>�R(R
R9R5(R(R�R�R�(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytencapsulate�s	sexception not properly restored(t	Exceptiontfail(RR�((R�R�R�s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_callbacks_protected�s


cs�ddl�dtfd��Y}|�}tj|�fd��}~~|�}|�|_tj|j�fd��}|�}||_~~dS(Ni����RcBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�scs
�j�S(N(R!(tignore(R (s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��Rcs
�j�S(N(R!(R�(R (s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��R(R RER9R5titc1(RRRFR<R�tc2((R s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_sf_bug_840829�s					cCsyddl}dtfd��Y}dtfd��Y}|�}||_tj||j�|_~~~|j�dS(Ni����tJcBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��stIIcBseZd�ZRS(cSs|jdS(N(R�(RR�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt	acallback�s(RRR�(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��s(R RER�R9R5R�R<R!(RR R�R�tI((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_callback_in_cycle_1�s			cCsvddl}dtfd��Y}ddd��Y}|�}||_tj||j�|_~~~|j�dS(Ni����R�cBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�sR�cBseZd�ZRS(cSs|jdS(N(R�(RR�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�s(RRR�(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�s((R RER�R9R5R�R<R!(RR R�R�R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_callback_in_cycle_2s			cCspddl}ddd��Y}|�|�}}||_||_tj||j�|_~~|j�dS(Ni����RcBseZd�ZRS(cSs|j|j|jdS(N(tmeR�R<(RR�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytcb2s(RRR�(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR1s((R R�R�R9R5R�R<R!(RR RR�R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_callback_in_cycle_3(s		cCs�ddl}dtfd��Y}ddd��Y}|�|�}}||_||_tj||j�|_~~~~|j�dS(Ni����RcBseZd�ZRS(cSs|j|j|jdS(N(R�R�R<(RR�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�Ks(RRR�(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRJstDcBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�Ps((	R RER�R�R9R5R�R<R!(RR RR�R�R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_callback_in_cycle_4@s			csddl}g�dtf�fd��Y}|d�|d�}}||_||_tj||j�|_tj||j�|_�fd�}tj||�}~~~|j�g�|j�|j�dg�|j|�d��2|j�|j�g�dS(Ni����Rcs eZd�Z�fd�ZRS(cSs
||_dS(N(t	attribute(Rtvalue((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRkscs�j|j�dS(N(R\RF(RR�(talist(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�ns(RRRR�((R�(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRjs	iics�jd�dS(NsC went away(R\(R�(R�(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytC_went_awaywssC went away(
R RERFR9R5R�R<RAR!R
(RR RR�R�R�R<((R�s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt#test_callback_in_cycle_resurrection\s$			

cs+ddl}g��fd�}dtf�fd��Y}|�|�}}||_||_|j}tj||�|_tj||j�|_tj||�}|j|�|�~~~~|j�g�|j	�|j�dg�|j|�d��2|j	�|j�g�dS(Ni����cs�jd�dS(Nssafe_callback called(R\(R�(R�(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt
safe_callback�sRcseZ�fd�ZRS(cs�jd�dS(Ns	cb called(R\(RR�(R�(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��s(RRR�((R�(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�sssafe_callback called(R RERR�R9R5R<RQRAR!R
(RR R�RRFtdR6texternal_wr((R�s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_callbacks_on_callback�s(				

cCs|jtj�dS(N(tcheck_gc_during_creationR9R5(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_gc_during_ref_creation�scCs|jtj�dS(N(R�R9RK(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_gc_during_proxy_creation�scCs�tj�}tjddd�tj�ddd��Y}d�}|�}|�}||_||�|_z|�}tj||�Wdtj|�XdS(NitAcBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��scWsdS(N((targs((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR6�s((R t
get_thresholdt
set_thresholdR!taR<R9R5(RRzt
thresholdsR�R6t
referencedR�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��s
					cCs#dtfd��Y}|�}dS(NtTargetcBseZd�ZRS(cSstj|�adS(N(R9R5tref_from_del(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt__del__�s(RRR�(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��s(RE(RR�tw((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_ref_created_during_del�scCs?tjt�}|jt|jddddd�tj�dS(Ni(R9R5R�RHRIRR R!(Rtr((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt	test_init�s"cCs�dtfd��Y}ddd��Y}g}tjt�tj||j�}d}tj�|j|�d�|j||g�tj||j�}d}tj�|j|�d�|j|||g�dS(NR�cBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��stBcBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��s((	RER9R5tintR\R
R R!RA(RR�R�tlR�tb((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_classes�s


c	Cs�td�}td�}td�}tj|�}tj|�}tj|�}tj|�}|j||k�|j||k�|j||k�|j||k�|j||k�|j||k�~~~tj�x*|||fD]}|j|�d�q�W|j||k�|j||k�|j||k�|j||k�|j	||k||k�|j	||k||k	�dS(Nii(
RR9R5R^R[R R!RQR
RA(	RRtytzR�R�RFR�R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt
test_equality�s.	
cCs�td�}td�}tj|�}tj|�}|jt|�td��~~tj�|jt|�td��|jtt|�dS(Ni*(	RR9R5RARR R!RHRI(RRR�R�R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_hashings
cCsndtfd��Y}tj�}|d�}}x(td�D]}||�||<}q?W~tj�dS(NRcBseZd�ZRS(csA|s
dStj|���fd�}tj||�|_dS(Ncs
��}dS(N((twparentR;(twself(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�2s(R9R5R�(RtparentR�((R�s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR.s
(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR-sid(RER9tWeakKeyDictionaryR
RaR R!(RRR�trootRFtn((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_trashcan_16602(s	(-RRR=R?RDRGRJROR8R>RURXRhRoRsRvRxRyRwR~RYR�R�R�R�R�R�R�R�R�R�R�Rtrequires_type_collectingR�R�R�R�R�R�R�R�R�R�R�(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR7_sR			
						
																		(	(			/	&							!	tSubclassableWeakrefTestCasecBs5eZd�Zd�Zd�Zd�Zd�ZRS(cs�dtjf�fd��Y�td�}�|dd�}|j|�|�|j|j�|j|jd�~|j|��|j|j�dS(NtMyRefcs,eZdd�fd�Z�fd�ZRS(i*cs&||_t�|�j||�dS(N(R�tsuperR(RtobR6R�(R�(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRBs	cst|_t�|�j�S(N(R-tcalledR�R	(R(R�(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR	Es	N(RRR
RR	((R�(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�AsRR�i(	R9R5RRQR^R�RAR�R@(RR;tmr((R�s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_subclass_refs@scCsdtjfd��Y}td�}||�}tj|�}|j||�|jtj|�||g�|jtj|�d�||�}|jtj|�d�tj|�}|jt|�d�|j||d�|j	||d�|j	||d�dS(NR�cBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�Rsi*iiii(
R9R5RtassertIsNotRAR�RTR]RQR`(RR�R;tr1tr2tr3trefs((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt-test_subclass_refs_dont_replace_standard_refsQscCs�dtjfd��Y}td�}||t�}||t�}|j||�tj|�}|j||�|j||�dS(NR�cBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�csi*(R9R5RtidtstrR�R�R`(RR�R;R�R�R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt*test_subclass_refs_dont_conflate_callbacksbscCs�dtjfd��Y}td�}||ddd�}|j|jd�|j|jd�|j|j�d�|jt	|d��dS(NR�cBs)eZdZd�Zd�Zd�ZRS(tslot1tslot2cSstjj|||�S(N(R9R5t__new__(R|R�R6R�R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�pscSs||_||_dS(N(R�R�(RR�R6R�R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRrs	cSs|j|jS(N(R�R�(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytmethus(R�R�(RRt	__slots__R�RR�(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�ns		i*tabctdeftabcdeft__dict__(
R9R5RR
RAR�R�R�R[R�(RR�R;R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_subclass_refs_with_slotsms	cs�dtjfd��Y}�fd�}t�}|||�}||_~~�j�jd�t�}|||�}|||�}||_||_~~~�j�jd�dS(NR�cBseZRS((RR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��scs�jd7_dS(Ni(R3(R�(R(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR6�si(R9R5RR;RAR3R�(RR�R6R;R�R�((Rs8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_subclass_refs_with_cycle~s"					(RRR�R�R�R�R�(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�>s
				tMappingTestCasecBsReZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&RS(%i
c
s�d}gt|�D]}t�^q}|�fd�t|�D��}|j�}yt|�Wntk
rwnX~tj�t|�}t	|�~tj�t|�}	|j
|d�|j
|	d�dS(Nic3s$|]\}}�||�VqdS(N((t.0R�R;(tcons(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pys	<genexpr>�si(RaRt	enumeratet	iteritemstnextt
StopIterationR R!R]R�RA(
Rt	dict_typeR�tNR�titemstdcttittn1tn2((R�s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytcheck_len_cycles�s"""



cCs|jtjd��dS(NcSs
||fS(N((R�R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��R(R�R9R�(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_keyed_len_cycles�scCs|jtjd��dS(NcSs
||fS(N((R�R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��R(R�R9tWeakValueDictionary(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_valued_len_cycles�scs'|jtjtj��xtdd�D]�}d}tjd�tj|||�gt|�D]}t�^qb}|�fd�|D��}~|j�}yt|�Wnt	k
r�nXt
|�}	~t
|�}
|j|	d�|j|	|�|j|
d�|j|
|	�q)WdS(Niidiic3s|]}�|�VqdS(N((R�R;(R�(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pys	<genexpr>�s(
t
addCleanupR R�R�RaR!RR�R�R�R]tassertGreaterEqualtassertLessEqual(RR�R�tthR�R�R�R�R�R�R�((R�s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytcheck_len_race�s(
"
cCs|jtjd��dS(NcSs
|dfS(Ni((R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��R(RR9R�(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_keyed_len_race�scCs|jtjd��dS(NcSs
d|fS(Ni((R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��R(RR9R(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_valued_len_race�scCsP|j�\}}xH|D]@}|jtj|�dd|�|j|||jd�qW|j�}|j�j�}|j�|j�|j||d�~~|jt	|�|j
�|d=|jt	|�|j
dd�~~|jt	|�dd�tj�}|jt
|jd�t�|d<|jt
|jd�dS(	Nis&wrong number of weak references to %r!s#wrong object returned by weak dict!s/cloning of weak-valued dictionary did not work!is/deleting object did not cause dictionary updates0deleting the values did not clear the dictionaryi(tmake_weak_valued_dictRAR9RTRQRR�tcopytsortR]tCOUNTRRHtKeyErrort__getitem__R(RtdicttobjectsR;titems1titems2((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_values�s0



cCs9|j�\}}xH|D]@}|jtj|�dd|�|j|j||d�qW|j�}|j�j�}|jt|�t|�d�~~|jt	|�|j
�|d=|jt	|�|j
dd�~~|jt	|�dd�td�}d	||<|j||�|j
d
|�dS(Nis&wrong number of weak references to %r!s#wrong object returned by weak dict!s.cloning of weak-keyed dictionary did not work!is/deleting object did not cause dictionary updates.deleting the keys did not clear the dictionaryi*s$What is the meaning of the universe?i"(tmake_weak_keyed_dictRAR9RTRQRR�R
tsetR]RRR`tassertNotIn(RRRR;RR((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_keyss,

cCsY|j�\}}|j|�|j�}|jt|�t|��t|�}xK|D]C}|�}|j||�|j|j||�|j|�qZW|jt|�d�t|�}|jtt|j	���t|��xQ|j	�D]C}|�}|j||�|j|j||�|j|�q�W|jt|�d�dS(Ni(
Rtcheck_iterstkeyrefsRAR]R�R`RR�titerkeyrefs(RRRR�tobjects2R<R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_keyed_iters s&

	(	cCss|j�\}}|j|�|j�}|jt|�t|��t|�}xX|D]P}|�}|j|||j�|j|j||jj�|j|�qZW|jt|�d�t|�}|jtt|j���t|��x^|j�D]P}|�}|j|||j�|j|j||jj�|j|�qW|jt|�d�dS(Ni(	R	Rt	valuerefsRAR]R�RR�t
itervaluerefs(RRRR�RR<R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_valued_iters9s&

	(	cCs"|j�}x!|j�D]}|j|�qW|jt|�dd�|j�}x|D]}|j|�q\W|jt|�dd�|j�}x!|j�D]}|j|�q�W|jt|�dd�|j�}x!|j�D]}|j|�q�W|jt|�dd�dS(Nis#iteritems() did not touch all itemss!__iter__() did not touch all keyss!iterkeys() did not touch all keyss%itervalues() did not touch all values(	R�R�R�RAR]tkeystiterkeystvaluest
itervalues(RRR�titemR R�R"tv((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRRs"
cCs�t|�}tt||���}t|�|d=tj�|jtt|��t|�t|�dg�~|jt|�|d�dS(Ni����i(	R]titertgetattrR�R R!R`R�RA(RRRt	iter_nameR�R�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt"check_weak_destroy_while_iteratingls

2cCsc|�� \}}|j||k�WdQX|��#\}}|jt|j|�WdQX|j||k�|��#\}}|jt|j|�WdQX|j||k�|��\}}|||<WdQX|j|||�tj|�}|��\}}|j|�WdQX|j||�|��\}}|j�WdQX|jt	|�d�dS(Ni(
R[RHR
R�tpopRAR
tupdatetclearR](RRttestcontextR�R%tddict((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt-check_weak_destroy_and_mutate_while_iteratingys$cs�|j�\��|j��d�|j��d�|j��d�|j��d�|j�\��tj��fd��}|j�|�dS(NR!R�R#Rc3sbzJt�j��}t|��j�j}tj�t|�|fVWdd}tj�XdS(N(	R&R�R�R*RR R!RR
(R�R%(RR(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR-�s

(RR)t
contextlibtcontextmanagerR/(RR-((RRs8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt&test_weak_keys_destroy_while_iterating�scs�|j�\��|j��d�|j��d�|j��d�|j��d�|j�\��tj��fd��}|j�|�dS(NR!R�R#Rc3sbzJt�j��}t|��j�j}tj�|t|�fVWdd}tj�XdS(N(	R&R�R�R*RR R!RR
(R�R�(RR(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR-�s

(R	R)R0R1R/(RR-((RRs8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt(test_weak_values_destroy_while_iterating�scCs:td�}tjid|6�}|j||d�dS(Niil(RR9R�RA(RR;R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt#test_make_weak_keyed_dict_from_dict�scCsItd�}tjid|6�}tj|�}|j||d�dS(Niil(RR9R�RA(RR;Rtdict2((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt.test_make_weak_keyed_dict_from_weak_keyed_dict�scCsLtj�}ttt|j��}x|D]}|j||<q+W||fS(N(R9R�tmapRRaRR(RRRR;((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR�s

cCs�|jttjj�|jttjii�|jttjdd�td�}xWdD]O}tji||6�}|jt|j��|g�|j|||�q[WdS(NiRRtiterable(((RRR8(	RHRIR9RRRRAR�R (RR;tkwR�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_make_weak_valued_dict_misc�s
cCsLtj�}ttt|j��}x|D]}|||j<q+W||fS(N(R9RR7RRaRR(RRRR;((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR	�s

c	Cs�|�}|||<|||<|jt|�d�|j�\}}|jt|�d�||krz|j||�n|j||�|j�\}}|jt|�d�||kr�|j||�n|j||�dS(Niii(RAR]tpopitemRQ(	Rtklasstkey1tvalue1tkey2tvalue2tweakdictR�R%((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt
check_popitem�s	

cCs&|jtjdt�dt��dS(NR=R?(RBR9RR(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_valued_dict_popitem�scCs&|jtjt�dt�d�dS(Nsvalue 1svalue 2(RBR9R�R(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_keyed_dict_popitem�scCs�|j||d�|�}|j||�}|j||�|j||�|j|j|�|�|j|||�|j||�}|j||�|j||�|j|j|�|�|j|||�dS(Ns9invalid test -- value parameters must be distinct objects(R�t
setdefaultRQR`tget(RR<tkeyR>R@RAR;((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytcheck_setdefault�s	cCs#|jtjdt�t��dS(NRG(RHR9RR(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt test_weak_valued_dict_setdefaultscCs |jtjt�dd�dS(Nsvalue 1svalue 2(RHR9R�R(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_keyed_dict_setdefaultscCs�|�}|j|�|jt|�t|��xc|j�D]U}|j||d�|j|�}|j|||�|j||j|��q?Wx^|j�D]P}|j||d�||}|j|||�|j||j|��q�WdS(Ns(mysterious new key appeared in weak dicts%original key disappeared in weak dict(R+RAR]R R`RFRQ(RR<RRAR�R%((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pytcheck_updates	

cCs|jtjit�d6t�d6t�t�6�|jttjj�tj�}|jt|jii�|jt|jdd	�|jt|j	��g�t
d�}xad
D]Y}tj�}|ji||6�|jt|j	��|g�|j|||�q�WdS(NiR�iRRRR8(((RRRR8(RKR9RRRHRIR+RAR�R R(RR�R;R9((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_valued_dict_update+s(
cCs5|jtjidt�6dt�6dt�6�dS(Niii(RKR9R�R(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_keyed_dict_update<scCs�tj�}td�}td�}d||<d||<|jt|�d�||=|jt|�d�|j|j�|g�dS(Nt1t2t	somethingii(R9R�RRAR]R (RR�to1RS((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_keyed_delitem@s

cCs�tj�}td�}td�}||d<||d<|jt|�d�|d=|jt|�d�|j|j�d|fg�dS(NRNRORPssomething elseii(R9RRRAR]R�(RR�RQRS((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_valued_delitemKs

cCs�tj�}td�}|jt|j|�|jt|j|�|jt|jd�|jt|jd�|jt|jdd�dS(NRNi
(	R9R�RRHR
R�RRIt__setitem__(RR�R;((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_weak_keyed_bad_delitemVscs�tj�}t�dtf��fd��Y}gtd�D]}||�^q>�x�D]}|j||<q]W~|j���j�t�d}x�D]}|d7}||=q�W|j	t
|�d�|j	|d�dS(NRcs,eZd�Zd�Z��fd�ZRS(cSs
||_dS(N(R�(RR�((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRmscSs
t|j�S(N(RR�(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRoscs �r�d=n|j|jkS(Ni����(R�(RR(tmutatetobjs(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRqs
(RRRRR((RVRW(s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRls		iiii(R9R�R&RERaR�R treverseR-RAR](RR�RR�R;tcount((RVRWs8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt!test_weak_keyed_cascading_deletesds %

	

cCs_tj�}t��Dx<td�D].}|jdt��}|j|d�~q#WWdQXdS(NiP�i
(R9RR1RaRERR�R
(RR�R�R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt$test_threaded_weak_valued_setdefault�s
cCsftj�}t��KxCtd�D]5}t�|d<|jdd�}|j|d�q#WWdQXdS(NiP�i
(R9RR1RaRR*R�R
(RR�R�R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyttest_threaded_weak_valued_pop�s

cCsftj�}t��KxCtd�D]5}t�}||d<|jt|�d�d}q#WWdQXdS(Ni@
i
i(R9RR1RaRRAR]R
(RR�R�R;((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt%test_threaded_weak_valued_consistency�s
	
('RRRR�R�RRRRRRRRRR)R/R2R3R4R6RR:R	RBRCRDRHRIRJRKRLRMRRRSRURZR[R\R](((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR��sJ												
																					-		(t
mapping_teststWeakValueDictionaryTestCasecBsMeZdZied�d6ed�d6ed�d6ZejZd�ZRS(s?Check that WeakValueDictionary conforms to the mapping protocoliR=iR?itkey3cCs
|jj�S(N(t!_WeakValueDictionaryTestCase__refR
(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt
_reference�s(	RRt__doc__RRaR9Rt	type2testRb(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyR_�s-	tWeakKeyDictionaryTestCasecBsMeZdZided�6ded�6ded�6ZejZd�ZRS(s=Check that WeakKeyDictionary conforms to the mapping protocoliR=iR?iR`cCs
|jj�S(N(t_WeakKeyDictionaryTestCase__refR
(R((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRb�s(	RRRcRRfR9R�RdRb(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyRe�s-	s� Doctest for examples in the library reference: weakref.rst

>>> import weakref
>>> class Dict(dict):
...     pass
...
>>> obj = Dict(red=1, green=2, blue=3)   # this object is weak referencable
>>> r = weakref.ref(obj)
>>> print r() is obj
True

>>> import weakref
>>> class Object:
...     pass
...
>>> o = Object()
>>> r = weakref.ref(o)
>>> o2 = r()
>>> o is o2
True
>>> del o, o2
>>> print r()
None

>>> import weakref
>>> class ExtendedRef(weakref.ref):
...     def __init__(self, ob, callback=None, **annotations):
...         super(ExtendedRef, self).__init__(ob, callback)
...         self.__counter = 0
...         for k, v in annotations.iteritems():
...             setattr(self, k, v)
...     def __call__(self):
...         '''Return a pair containing the referent and the number of
...         times the reference has been called.
...         '''
...         ob = super(ExtendedRef, self).__call__()
...         if ob is not None:
...             self.__counter += 1
...             ob = (ob, self.__counter)
...         return ob
...
>>> class A:   # not in docs from here, just testing the ExtendedRef
...     pass
...
>>> a = A()
>>> r = ExtendedRef(a, foo=1, bar="baz")
>>> r.foo
1
>>> r.bar
'baz'
>>> r()[1]
1
>>> r()[1]
2
>>> r()[0] is a
True


>>> import weakref
>>> _id2obj_dict = weakref.WeakValueDictionary()
>>> def remember(obj):
...     oid = id(obj)
...     _id2obj_dict[oid] = obj
...     return oid
...
>>> def id2obj(oid):
...     return _id2obj_dict[oid]
...
>>> a = A()             # from here, just testing
>>> a_id = remember(a)
>>> id2obj(a_id) is a
True
>>> del a
>>> try:
...     id2obj(a_id)
... except KeyError:
...     print 'OK'
... else:
...     print 'WeakValueDictionary error'
OK

t
libreftestcCs1tjttttt�tjtj	t
�dS(N(Rtrun_unittestR7R�R_ReR�trun_doctestR(tmodulesR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt	test_mainst__main__(#R R(tunittestRZR9RqR0R
RttestRR
R�RRR
RRRRR1R1tTestCaseR2R7R�R�R^tBasicTestMappingProtocolR_ReRgt__test__RkR(((s8/usr/local/python-2.7/lib/python2.7/test/test_weakref.pyt<module>sF				���g��X
	
© 2025 GrazzMean