a ze@sddlmZddlmZmZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZdaGdddejZGdddejZGdd d ejZejjGd d d ejZejjGd d d ejZedkr edS))support)assert_python_okassert_python_failureNc@s$eZdZddZddZddZdS)DisplayHookTestcCstj}t}|dWdn1s,0Y||d|tjdt`t}|dWdn1s~0Y||d|t td | t |tj }zt` | t |dW|t_ n|t_ 0dS)N*z42 _)sys__displayhook__rZcaptured_stdout assertEqualgetvaluebuiltinsr assertTruehasattr assertRaises TypeErrorstdout RuntimeError)selfZdhoutrrA/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_sys.pytest_original_displayhooks  & & z)DisplayHookTest.test_original_displayhookcCs<tj}z(t`tddd}|tt|W|t_n|t_0dS)N42single)r displayhookcompilerreval)rrcoderrrtest_lost_displayhook5s  z%DisplayHookTest.test_lost_displayhookcCsTdd}ttd|*tddd}|tt|Wdn1sF0YdS)NcSstdSN ValueError)objrrrbaddisplayhook?sz?DisplayHookTest.test_custom_displayhook..baddisplayhookrrrr)r swap_attrr rrr#r)rr%rrrrtest_custom_displayhook>s z'DisplayHookTest.test_custom_displayhookN)__name__ __module__ __qualname__rr r'rrrrrs rc@s$eZdZddZddZddZdS)ExceptHookTestc Csz tdWnZtyf}zBt}tjtWdn1sH0YWYd}~n d}~00||d| t tjdS)NrValueError: 42 ) r#rcaptured_stderrr __excepthook__exc_inforr endswithrrrexcerrrrrtest_original_excepthookIs  Bz'ExceptHookTest.test_original_excepthookc CsttdtztddWnZty~}zBt}tjt Wdn1s`0YWYd}~n d}~00Wdn1s0Y| }| d|| d|| | ddS)Nignoremsg)sbytes_filename{rtextz% File "b'bytes_filename'", line 123 z text zSyntaxError: msg )warningscatch_warnings simplefilter BytesWarning SyntaxErrorrr-r r.r/r assertInrr0r1rrrtest_excepthook_bytes_filenameTs   `  z-ExceptHookTest.test_excepthook_bytes_filenamecCsPtjd}tdddWdn1s00Y|d|vdS)Nstderr1zETypeError: print_exception(): Exception expected for value, str found)testrcaptured_outputr excepthookrr )rr@rrrtest_excepthookes ,zExceptHookTest.test_excepthookN)r(r)r*r4r?rFrrrrr+Gs r+c@seZdZddZddZddZddZd d Zd d Ze j j d dZ e j j ddZ ddZddZeeeddddZe j jddZddZe j jddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Z d-d.Z!d/d0Z"e j j d1d2Z#d3d4Z$ee j j%d5ee&e'(d6kd7d8d9Z)e*ej+ej,kd:d;d<Z-ddd>d?Z.d@dAZ/dedBdCZ0dDdEZ1dFdGZ2dHdIZ3dJdKZ4e j j dLdMZ5eeedNdOdPdQZ6dRdSZ7dTdUZ8dVdWZ9eeedXdYdZd[Z:d\d]Z;d^d_Z.check_exit_messagez?import sys; sys.stderr.write("unflushed,"); sys.exit("message")sunflushed,messagez)import sys; sys.exit("surrogates:\uDCFF")ssurrogates:\udcffzimport sys; sys.exit("h\xe9")shzlatin-1)PYTHONIOENCODING) rrr rM SystemExit assertIsNone exceptionrrr r)rcmrTrr3rUrrIr test_exittsJ &    ( ( * *    zSysModuleTest.test_exitcCs$|ttjd|ttdS)Nr)rrr getdefaultencodingassertIsInstancestrrIrrrtest_getdefaultencodingsz%SysModuleTest.test_getdefaultencodingc Cs|ttj|ttjd|ttjd|ttjdt}||dk|z:ddd|fD]}t||t|qdWt|n t|0dS)Naggg?gh㈵>g?g@)rrr setswitchintervalr#getswitchintervalrZassertAlmostEqual)rZorignrrrtest_switchintervals z!SysModuleTest.test_switchintervalcCs^|ttjdt}|ttj|ttjdtd|tdt|dS)Nrii')rrr getrecursionlimitsetrecursionlimitr#r )roldlimitrrrtest_recursionlimits z!SysModuleTest.test_recursionlimitc sttdrtr|dt}fddzVdD]B}zt|Wnty^Yq6Yn0|t|tq6Wt|n t|0dS)Ngettracez(fatal error if run with a trace functioncs dSr!rrfrrrksz5SysModuleTest.test_recursionlimit_recovery..f) 2Kd)rr riZskipTestrerfRecursionErrorr)rrgdepthrrjrtest_recursionlimit_recoverys     z*SysModuleTest.test_recursionlimit_recoveryc sddlmfddt}zJtddD],}|dkrJ|d}n |d d }||q4Wt|n t|0dS) Nr)get_recursion_depthcsd}||krVt}t|Wdn1s80Yt|jdn ||dS)Nz\cannot set the recursion limit to [0-9]+ at the recursion depth [0-9]+: the limit is too low)rrsr rfZ assertRegexr^rY)rtlimitrecursion_depthrZrvrset_recursion_limit_at_depthrrrzs ( zZSysModuleTest.test_setrecursionlimit_recursion_depth..set_recursion_limit_at_depthrr)rlrmrnrorpr|rn)_testinternalcapirvr rerf)rrgrwrtrryr&test_setrecursionlimit_recursion_depths     z4SysModuleTest.test_setrecursionlimit_recursion_depthcCstd}tj^dD]H}tjtjd||gtj d}| d}| |j |j | d|qWdn1sx0YdS)Nz import sys def f(): try: f() except RecursionError: f() sys.setrecursionlimit(%d) f())rnrrrKr@rAsNFatal Python error: _Py_CheckRecursiveCall: Cannot recover from stack overflow)textwrapdedentrCrZSuppressCrashReport subprocessPopenr executablePIPE communicater returncoder>)rrisubr3rrrtest_recursionlimit_fatalerrors  z,SysModuleTest.test_recursionlimit_fatalerrorcCsvtjtdt}|t|d||dt||dt||dt||dt||dt | t t j |d||jt||jt||jt||jt||jt ||jt||jt||jt||jt||d|j||d|j||d|j||d|j||d|jt\}}}}}dS)NgetwindowsversionrrAr}r~)rCr get_attributer rr lenr]intr^r IndexErroroperatorgetitemmajorminorZbuildplatformZ service_packZservice_pack_minorZservice_pack_majorZ suite_maskZ product_type)rvZmajminZbuildnoZplatZcsdrrrtest_getwindowsversion+s0z$SysModuleTest.test_getwindowsversioncCs|ttjtddS)Nr)rrr call_tracingtyperIrrrtest_call_tracingIszSysModuleTest.test_call_tracingsetdlopenflagsztest needs sys.setdlopenflags()cCsf|ttd|ttjdt}|ttjt|d|t|dt|dS)NgetdlopenflagsrrA)rrr rrrrr )rZoldflagsrrrtest_dlopenflagsLszSysModuleTest.test_dlopenflagscCsd|ttjtd}da|td|db|td|ttdr`|tt dS)NrAgettotalrefcount) rrr getrefcountrcr rr]rr)rcrrr test_refcountWs  zSysModuleTest.test_refcountcCs>|ttjdd|ttjd|tjjtj udS)Nri5w) rrr _getframer#rrG test_getframe__code__f_coderIrrrrgszSysModuleTest.test_getframecsrddlddl}gfdd}fddj|d}||tdd}t }|D]}| |t | |dq }||||||||}||tu||}||} t| D]\} \} } } }| dkrq"q|d ||d | | d\} } } }|| d ||d d g|dS)Nrcs dSr!rr)g456rrf123|sz/SysModuleTest.test_current_frames..f123cs"dSr!)append get_identsetwaitr) entered_gleave_g thread_info threadingrrrsz/SysModuleTest.test_current_frames..g456)targetrArz)didn't find f123() on thread's call stackzg456()rzleave_g.wait()zentered_g.set())r tracebackEventThreadstartrr rr _current_framesr]r assertGreaterrr>poprr extract_stack enumerateZfailrjoin)rrrtZ thread_iddtidZmain_idframestackrfilenamelinenofuncnameZ sourceliner)rrrrrrtest_current_framespsB           z!SysModuleTest.test_current_framescCs(|tjt|tjt|tjd|tjt |tj t |tj t |tj t |tjt |ttjd|tjjd|ttjd|tjjddk|tjjdk|ttjjt|ttjjt|tjt|ttjd|tjjdtjjtddD]2}|t|tjjdtjjdd tjjq6|tjj t|tjj!t|tjj"tt#$d }tjj%d vr(|tjj&d d h|tjj'hd|dkr|tjj%dn0|dkr|tjj%dn|tjj%ddhn ||d|(tjj)d|tjj)d|tj*t|tj+t|tj+d|tj,t |tj-t |tj.t |tj/t |tj0t tj1}||ddt |t|d||dt||dt||dt||dd||dt||j2t||j3t||j4t||j5d||j6t||d|j2||d|j3||d|j4||d|j5||d|j6||dk|tj7t |tj7dtj,8ds$|tj9t dS)N)littlebig rrrrA rpz'sys.hash_info.modulus {} is a non-primeZPy_HASH_ALGORITHM> siphash24fnv @>rrrrir}alphabeta candidatefinalr~)rArr)Zshortlegacywin):r]r api_versionrargvlistr> byteorderbuiltin_module_namestuple copyrightr^ exec_prefixbase_exec_prefixrr r float_inforadixint_inforbits_per_digit sizeof_digitr hexversion hash_info assertLessmoduluswidthrangepowformatinfnanimag sysconfigZget_config_var algorithm hash_bits seed_bitsassertGreaterEqualcutoffmaxsize maxunicoderprefix base_prefix platlibdirversion version_inforrmicro releaselevelserialfloat_repr_stylerQabiflags)rxZalgovirrrtest_attributess    zSysModuleTest.test_attributescCs6tj}|t|d||jd||jddS)Nr})ntZpthreadZsolarisN) semaphorez mutex+condN)r rr rr>namelock)rinforrrtest_thread_infoszSysModuleTest.test_thread_infocCs|tjjtjjdSr!)r r __stdout__encoding __stderr__rIrrr test_43581 szSysModuleTest.test_43581cCs~td7a|ttjdtt}|t||u|}|t||uGdddt}|ttj|ddS)NrAznever interned beforec@seZdZddZdS)z$SysModuleTest.test_intern..ScSsdS)Nr7rrIrrr__hash__sz-SysModuleTest.test_intern..S.__hash__N)r(r)r*rrrrrSsrabc)INTERN_NUMRUNSrrr internr^rswapcase)rss2rrrr test_interns  zSysModuleTest.test_interncCs|tjd}|D]B}|ttj|||dkr8tnt}|tttj|||q|t tj|t tjt || tjj hddS)N)debuginspect interactiveoptimizedont_write_bytecode no_user_siteno_siteignore_environmentverbose bytes_warningquiethash_randomizationisolateddev_mode utf8_moder'>rrAr) rr flagsrboolrr rgetattrreprrr>r()rattrsattr attr_typerrrtest_sys_flags"s zSysModuleTest.test_sys_flagscCspt|}|t|Wdn1s.0Y|t||Wdn1sb0YdSr!)rrr__new__)rZsys_attrr/rrrassert_raise_on_new_sys_type2s  $ z*SysModuleTest.assert_raise_on_new_sys_typecCs|tjdSr!)r2r r)rIrrrtest_sys_flags_no_instantiation;sz-SysModuleTest.test_sys_flags_no_instantiationcCs|tjdSr!)r2r rrIrrr&test_sys_version_info_no_instantiation>sz4SysModuleTest.test_sys_version_info_no_instantiationcCs tjtd|tdS)Nr)rCrrr r2rrIrrr+test_sys_getwindowsversion_no_instantiationAsz9SysModuleTest.test_sys_getwindowsversion_no_instantiationcCs tdSr!)r _clear_type_cacherIrrrtest_clear_type_cacheFsz#SysModuleTest.test_clear_type_cachecCsttj}d|d<tjtjddgtj|d}|d }dtj  d}| ||d|d<tjtjddgtj|d}|d }| |d d |d<tjtjddgtjtj|d }|\}}| |d | d || d|d|d<tjtjddgtjtj|d }|\}}| |d | d || d|d|d<tjtjddgtj|d}|d }| |ddS)Ncp424rVrKzprint(chr(0xa2))renvr¢z ascii:replace?rR)rr@r:rLsUnicodeEncodeError:s'\xa2'zascii:z:surrogateescapezprint(chr(0xdcbd)))dictosenvironrrr rrrstriplinesepencoder r>)rr:prrSr3rrrtest_ioencodingJsL           zSysModuleTest.test_ioencodingz*requires OS support of non-ASCII encodingsFz$requires FS encoding to match localecCs^ttj}d|d<tjtjddtjj gtj |d}| d }| |ttjj dS)NrrVrKz print(%a)r9r)r>r?r@rrr rrCr FS_NONASCIIrrrAr fsencode)rr:rDrrrrtest_ioencoding_nonasciius   z&SysModuleTest.test_ioencoding_nonasciizTest is not venv-compatiblec Cs|tjtjtjtjtjtj}tj gdtjtj |d}| d}| d}|||dttjddgdS)N)Z nonexistentrKzEimport sys; print(sys.executable.encode("ascii", "backslashreplace")))rrcwdrASCIIzb''rRbackslashreplace)r r?pathabspathr rdirnamerealpathrrrrrAdecoderr>r,rC)rZ python_dirrDrrrrrtest_executables  zSysModuleTest.test_executableNcCs(||t||r$|||dSr!)ZassertIsNotNonecodecslookupr rZ fs_encodingrSrrrcheck_fsencodings  zSysModuleTest.check_fsencodingcCs,t}tjdkrd}nd}|||dS)Ndarwinzutf-8)r getfilesystemencodingrrUrTrrrtest_getfilesystemencodings  z(SysModuleTest.test_getfilesystemencodingc Cstj}||d<d|d<dd}tjddd|g}|rB|d |durT||d <n |d dtj |tj tj |d d }| \}} |S) NLC_ALL0ZPYTHONCOERCECLOCALE ) import syszdef dump(name):z std = getattr(sys, name)z( print("%s: %s" % (name, std.errors))z dump("stdin")zdump("stdout")zdump("stderr")z-Xzutf8=0rKz-IrVT)rr@r:universal_newlines) r?r@copyrr rrrrrrSTDOUTr) rlocaler&rr:rargsrDrr@rrrc_locale_get_error_handlers$      z(SysModuleTest.c_locale_get_error_handlercCs|j|dd}||d|j|dd}||d|j|dd}||d|j|d d}||d|j|d d}||d|j|d d}||ddS) NT)r&zHstdin: surrogateescape stdout: surrogateescape stderr: backslashreplace z:ignore)rz6stdin: ignore stdout: ignore stderr: backslashreplace z iso8859-1z6stdin: strict stdout: strict stderr: backslashreplace z iso8859-1::r)rbr )rr`rrrrcheck_locale_surrogateescapes0z*SysModuleTest.check_locale_surrogateescapecCs|ddS)NCrdrIrrrtest_c_locale_surrogateescapesz+SysModuleTest.test_c_locale_surrogateescapecCs|ddS)NZPOSIXrfrIrrr!test_posix_locale_surrogateescapesz/SysModuleTest.test_posix_locale_surrogateescapecCsddddd}|ttjd|ttjd|ttjd|ttjd tjj}||dd |j|jf|jd >|jd >B|jd >B||j d>B|j d>B}|tjj ||tjj tjj dS)Nrlr rr rr cache_tagrrr~r)rrr implementationrr rrrrrrr lower)rZlevelsrrrrrtest_implementations$   z!SysModuleTest.test_implementationcCsBddlm}ddg}||\}}}|d||ttjddS)Nr)rrKz#import sys; sys._debugmallocstats()sfree PyDictObjectsT)test.support.script_helperrr>rrr _debugmallocstats)rrraretrr3rrrtest_debugmallocstatss   z#SysModuleTest.test_debugmallocstatsgetallocatedblocksz0sys.getallocatedblocks unavailable on this buildc Csz ddl}Wnty&t}Yn@0z |}Wn(ty\}zd}WYd}~nd}~00|dv}t}|t |t |r| |dn | |dz| |tWntyYn0tt}|||tt}||t|d|ddS)NrT)ZpymallocZpymalloc_debugrn) _testcapi ImportErrorr with_pymallocZpymem_getallocatorsnamerr ruassertIsrrrrrrAttributeErrorgcZcollectZassertLessEqualr>r)rrvrxZ alloc_namer2r`brrrrtest_getallocatedblockss0      z%SysModuleTest.test_getallocatedblockscCs8|tdd}td|\}}}||ddS)NFaif 1: import sys class AtExit: is_finalizing = sys.is_finalizing print = print def __del__(self): self.print(self.is_finalizing(), flush=True) # Keep a reference in the __main__ module namespace, so the # AtExit destructor will be called at Python exit ref = AtExit() rKsTrue)ryr is_finalizingrr rstriprrrTrr@rrrtest_is_finalizing:sz SysModuleTest.test_is_finalizingcCs@d}td|\}}}|}|d|d|d|ddS)Nzif 1: import sys class A: def __del__(self, sys=sys): print(sys.flags) print(sys.float_info) a = A() rKs sys.flagsrssys.float_inforA)r splitlinesr>rrrTrr3rrrtest_issue20602Os zSysModuleTest.test_issue20602cCsDd}td|\}}}||d||d||ddS)Nzif 1: import struct, sys class C: def __init__(self): self.pack = struct.pack def __del__(self): self.pack('I', -42) sys.x = C() rKrrL)rr rrrrr&test_sys_ignores_cleaning_up_user_data^s   z4SysModuleTest.test_sys_ignores_cleaning_up_user_datagetandroidapilevelzneed sys.getandroidapilevel()cCs$t}||t||ddS)Nr)r rr]rr)rlevelrrrtest_getandroidapilevelos z%SysModuleTest.test_getandroidapilevelcsdfdd}gd}|d||d||d|dd|dd|d|dd|dd|d |d g|d |d g|dd >||d d >|d g|d|dS) Nzif 1: import sys def f1(): 1 / 0 def f2(): f1() sys.tracebacklimit = %r f2() cs<tjtjd|gtjd}|d}||dS)NrKrrA)rrr rrrr r)tracebacklimitrSrDrrrrrchecks  z4SysModuleTest.test_sys_tracebacklimit..check)s"Traceback (most recent call last):s& File "", line 8, in s File "", line 6, in f2s File "", line 4, in f1s#ZeroDivisionError: division by zerorlr}rrArrrr)rrrrrrtest_sys_tracebacklimitvs   z%SysModuleTest.test_sys_tracebacklimitcCs |ttjtttjdSr!)r rr meta_pathrrIrrrtest_no_duplicates_in_meta_pathsz-SysModuleTest.test_no_duplicates_in_meta_pathZ_enablelegacywindowsfsencodingz*needs sys._enablelegacywindowsfsencoding()cCs:d}tdd|\}}}|dd}||ddS)N)r\z$sys._enablelegacywindowsfsencoding()zCprint(sys.getfilesystemencoding(), sys.getfilesystemencodeerrors())rKz; rRreplacez mbcs replace)rrrPrr rrrr#test__enablelegacywindowsfsencodingsz1SysModuleTest.test__enablelegacywindowsfsencoding)N)FN)>r(r)r*rJr[r_rdrhrurCr cpython_onlyrrrrunittestZ skipUnlessrr rZ refcount_testrrZ reap_threadsrrr rrr0r2r3r4r5r7rErFrWr`getpreferredencodingrHZskipIfrrrQrUrXrbrdrgrhrprtr}rrrrrrrrrrrrGosB  #      @R  +     &  '  ! rGc@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)UnraisableHookTestcCsTddl}ddl}d|}z.|||||jt|||j||dWd}Sd}0dS)NrException ignored )exc_type exc_value exc_tracebackerr_msgobject)rvtypeswrite_unraisable_excSimpleNamespacer __traceback__)rr2rr$rvrZerr_msg2rrrrs  z'UnraisableHookTest.write_unraisable_excc CsdD]}|j|dd}tjdT}tjtdtj"|td||Wdn1sb0YWdn1s0Y| }|dur| d|d|d |n| d |d || d || d |Wdq1s0YqdS) N)Nz original hook)rz an objectr@unraisablehookrrz: r[zException ignored in: #Traceback (most recent call last): r,) subTestrCrrDr&r __unraisablehook__rr#r r>)rrr$r@r3rrrtest_original_unraisablehooks N z/UnraisableHookTest.test_original_unraisablehookc s\Gddd}GdddtGfddd}||fD]}|||}tjD}tjtdtj~Wdn1s0YWdn1s0Y|}| d|| |j j || d || d |||ur| d|| d |n| d || d || | dWdq81sL0Yq8dS)Nc@seZdZddZdS)zFUnraisableHookTest.test_original_unraisablehook_err..BrokenDelcSstd}|dS)N del is brokenr"rr2rrr__del__szNUnraisableHookTest.test_original_unraisablehook_err..BrokenDel.__del__Nr(r)r*rrrrr BrokenDelsrc@seZdZddZdS)zOUnraisableHookTest.test_original_unraisablehook_err..BrokenStrExceptioncSs tddS)Nzstr() is broken ExceptionrIrrr__str__szWUnraisableHookTest.test_original_unraisablehook_err..BrokenStrException.__str__N)r(r)r*rrrrrBrokenStrExceptionsrcseZdZfddZdS)zOUnraisableHookTest.test_original_unraisablehook_err..BrokenExceptionDelcs}|dSr!rrrrrrszWUnraisableHookTest.test_original_unraisablehook_err..BrokenExceptionDel.__del__NrrrrrBrokenExceptionDelsrrzException ignoredz test_sys.pyz raise exczr#rr[)rrrCrr-r&r rr r>rr*rr0)rrrZ test_classr$r@reportrrr test_original_unraisablehook_errs.   >       z3UnraisableHookTest.test_original_unraisablehook_errc CsGddd}tjV}tjtdtj$||jdd}Wdn1sV0YWdn1st0Y| }d}| |d|dS)Nc@seZdZGdddZdS)zMUnraisableHookTest.test_original_unraisablehook_exception_qualname..Ac@seZdZGdddeZdS)zOUnraisableHookTest.test_original_unraisablehook_exception_qualname..A.Bc@s eZdZdS)zQUnraisableHookTest.test_original_unraisablehook_exception_qualname..A.B.XNr(r)r*rrrrXsrN)r(r)r*rrrrrrBsrN)r(r)r*rrrrrAsrrr6r$/test_original_unraisablehook_exception_qualnamez..A.B.X) rCrr-r&r rrrrr r>)rrr@rSrZtestNamerrrrs   @zBUnraisableHookTest.test_original_unraisablehook_exception_qualnamec Csrtd}tjtdtjD|tt|Wdn1sF0YWdn1sd0YdS)Nrr) r#rCrr&r rrrrrrrr'test_original_unraisablehook_wrong_types   z:UnraisableHookTest.test_original_unraisablehook_wrong_typecsdfdd}t}zztjtd|N|tdd|}dD]"}|t |t |||fqDWdn1s|0YWd}dn d}d0dS)Ncs|dSr!rraZ hook_argsrr hook_func sz@UnraisableHookTest.test_custom_unraisablehook..hook_funcrrz custom hookz/exc_type exc_value exc_traceback err_msg object) rrCrr&r rr#splitr r+)rrr$rSr.rrrtest_custom_unraisablehooks"    &z-UnraisableHookTest.test_custom_unraisablehookc Csdd}tjdR}tjtd|"|tdddWdn1sN0YWdn1sl0Y|}|d|d||d ||d |dS) NcWs tddS)Nzhook_func failedrrrrrrszEUnraisableHookTest.test_custom_unraisablehook_fail..hook_funcr@rrzcustom hook failz)Exception ignored in sys.unraisablehook: r[rzException: hook_func failed ) rCrrDr&r rr#r r>)rrr@r3rrrtest_custom_unraisablehook_fails @ z2UnraisableHookTest.test_custom_unraisablehook_failN) r(r)r*rrrrrrrrrrrrs(rcsleZdZddZejjZddZddZddZ fd d Z d d Z d dZ ddZ ddZddZZS) SizeofTestcCs*td|_tjj|_ddl}|j|_ dS)NPr) structcalcsizerr rr longdigitrZSIZEOF_PYGC_HEAD gc_headsize)rrrrrsetUp/s  zSizeofTest.setUpcCsHtjj}|j}|td|d|j|tg|d|dS)NTrPn)rCr calcvobjsizerr r getsizeofr)rvsizeZgc_header_sizerrrtest_gc_head_size7szSizeofTest.test_gc_head_sizecCsGddd}|ttj|Gddd}|ttj|dg}|t|||Gddd}|ttj||t|||Gdd d t}|t|tjtj|j |t $t|tjd Wdn1s0Y|tt|d Wdn1s00Y|tt f&t|tj d Wdn1sv0YdS) Nc@seZdZddZdS)z)SizeofTest.test_errors..BadSizeofcSstdSr!r"rIrrr __sizeof__Bsz4SizeofTest.test_errors..BadSizeof.__sizeof__Nr(r)r*rrrrr BadSizeofAsrc@seZdZddZdS)z-SizeofTest.test_errors..InvalidSizeofcSsdSr!rrIrrrrGsz8SizeofTest.test_errors..InvalidSizeof.__sizeof__Nrrrrr InvalidSizeofFsrsentinelc@seZdZddZdS)z+SizeofTest.test_errors..FloatSizeofcSsdS)Ng@rrIrrrrNsz6SizeofTest.test_errors..FloatSizeof.__sizeof__Nrrrrr FloatSizeofMsrc@seZdZddZdS)z.SizeofTest.test_errors..OverflowSizeofcSst|Sr!)rrIrrrrTsz9SizeofTest.test_errors..OverflowSizeof.__sizeof__NrrrrrOverflowSizeofSsrrAr) rr#r rrryrr rr OverflowError)rrrrrrrrr test_errors@s&  2 .zSizeofTest.test_errorscCsFtjj}|td|d|j|tdd|d|jdS)NTrr)rCrrr r rr)rsizerrr test_default_szSizeofTest.test_defaultc' sJ tj}tjjtjj}jd|djtddddg}|D]"}t |}||d| qNt t dd|d d d |d d d d}|j ddfdd}||j d||j ddd}||j d|d tdd dtjdddl} | jjdddl} | jjdtjdijdiddd id|ddd|d d d!d"d#dd$d%dd&} | d|dd'd(|d idididt id)t id)t id)t id)Gd*d+d+t} | jdtd,t dddddd-t!dddddd-t"ddd dd-t#dddl$} ddl%}| &|j'j(}|d.t)gd/t*ddt+dd0t,j-|dj.tt,j-ddl/}d1}|0}t|j1j2}t|j1j3}|j1j4|j1j5||d }||d2|d3d|dd4d5}|d6Gfd7d8d8}d9d:}|d;t d<d=ddl6}|7dddggd>gd?g}|D]&}t8||d@t|j.qt gd=t*gdd|dd |djdA|djd!t,j9j:}t||dd!jt|d!d |dd!jt|d!|dd"jt;dBddt<dtdGfdCd+d+t} t t=d dDt*ddt=d dEt=dFdEd}gt=d(t=dGg}dH|ddI}|D]}t|}|dkr\d }|d!}|}||kr~|d >}qh|dkrt>||t?||n4t>||||dt?||||dqBt t>dJt@ddKtAtdKdL|dd>|dd"j.dM}||}t|||dN}GdOdPdPt}|||dQdd|d |jddj.|} d | _B| _C| _D| _E| _F| _G| _H| _I|||dQd'd(|d |jdd(j.gdR}dS}!|!dT}"|"d}#|D]}tJtK|}$|$dUkrp|!t|d }%n\|$dVkr|"t|d }%n<|$dWkr|"d!t|d }%n|"d#t|d }%||%q@tLdX}||"d#tM|dYdZ||"d#d#ddlN}&|&Otd[|&Ptd[dS)\NTrZ5PrLuiZn2PiZnPrcrAs xxxxxxxxxxrcsdfdd}|S)NrcsSr!rrrrrinner}sz.get_cell..innerr)rrrrget_cell{s z-SizeofTest.test_objecttypes..get_cellrrcst||dSr!)rr r)r`Z expected_sizerIrrcheck_code_sizesz4SizeofTest.test_objecttypes..check_code_sizeZ6i13Pcsfdd}|S)NcsSr!rrrrrrsz=SizeofTest.test_objecttypes..get_cell2..innerr)rrrrr get_cell2s z.SizeofTest.test_objecttypes..get_cell2Z2dZ3PPPZ3PPZ3P2PZ2PZnQ2Pr`Z2nP2nrrZn2Prr}r~)rArr}r~rrrrrmrlZP2nPnc@s eZdZdS)&SizeofTest.test_objecttypes..CNrrrrrrerLreZ5Pbz 5Pb 2P2nPZ32B2iBZn3PrZ 5P2c4P3icZ3icSsdSr!rrrrrfuncrLz)SizeofTest.test_objecttypes..funcZ13Pcs@eZdZeddZeddZededdS)z&SizeofTest.test_objecttypes..ccSsdSr!rrrrrfoosz*SizeofTest.test_objecttypes..c.foocSsdSr!r)clsrrrbarsz*SizeofTest.test_objecttypes..c.barZPPN)r(r)r* staticmethodr classmethodrrrrrrrs   rcss dVdS)NrArrrrrget_genrLz,SizeofTest.test_objecttypes..get_genZPb2PPP4PrZlP)rArr})rB23rrZPnPPPcs@eZdZddZddZddZeeeedZedd S) rcSs|jSr!Z_C__xrIrrrgetxrLz+SizeofTest.test_objecttypes..C.getxcSs ||_dSr!r)rvaluerrrsetxrLz+SizeofTest.test_objecttypes..C.setxcSs|`dSr!rrIrrrdelxrLz+SizeofTest.test_objecttypes..C.delxrZ4PiN)r(r)r*rrrpropertyrrrrrres Z4lZ4PirnZ3nPZ2nPZP3n3PrZP2nPI13Pl4Pn9Pn11PIPPZ3P36P3P10P2P5Pc@s eZdZdS)z2SizeofTest.test_objecttypes..newstyleclassNrrrrr newstyleclass=rLrZ2nP2n0P)Zd1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111udÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿuPĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀĀu,￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿￿ux𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀𐀀u􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿􏿿ZnnbPZnPnrii@zrZ2Pn2P)QrrrCr calcobjsizer check_sizeofrr bytearray __alloc__iter __closure__rcomplexr^rodatetimeZ timedeltaZdays collections defaultdictdefault_factoryr__add____iter__keysvaluesitemsr__dict__ BaseExceptionUnicodeEncodeErrorUnicodeDecodeErrorUnicodeTranslateErrorEllipsisrRZencodings.iso8859_3 charmap_build iso8859_3Zdecoding_tablerreversedfloatr rrr currentframer co_cellvars co_freevars co_stacksize co_nlocalsrefinditerrrrrNotImplementedrr frozensetslicesuperr`r|rrerkghordmaxchrrweakrefrefproxy)'rrrZsamplessamplerrrrrrZlongdictrerR encodingsrZ CO_MAXBLOCKSZncellsZnfreesextrasrrrrZ PyLong_BASEZ PySet_MINSIZErZminusedtmpZnewsizefmtroZ asciifieldsZ compactfieldsZ unicodefieldsZmaxcharLr __class__)rrrrtest_objecttypesds*  *&   " $ $      "0"     zSizeofTest.test_objecttypescCsHt|t|}t|r2t|s2||j7}|t||dSr!)r rrrr{Z is_trackedrr )rr$baseextrarSrrr check_slotsns zSizeofTest.check_slotsc Cs|j}Gdddt}||tdGdddt}||gddgidGdd d t}||gdGd d d t}||tdGd d d t}||tdddlm}Gddd|}||gd|gdddS)Nc@seZdZdZdS)z!SizeofTest.test_slots..BAr`r|rNr(r)r* __slots__rrrrBAxsr0rc@seZdZdZdS)z SizeofTest.test_slots..Dr-Nr.rrrrD{sr1rrc@seZdZdZdS)z SizeofTest.test_slots..Lr-Nr.rrrrr&~sr&c@seZdZdZdS)z SizeofTest.test_slots..Sr-Nr.rrrrrsrc@seZdZdZdS)z!SizeofTest.test_slots..FSr-Nr.rrrrFSsr2r) OrderedDictc@seZdZdZdS)z!SizeofTest.test_slots..ODr-Nr.rrrrODsr4)r,rr>rrrrr3) rrr0r1r&rr2r3r4rrr test_slotsts zSizeofTest.test_slotscCstjj}tjj}|j}ddl}|||dztWn4tylt d}|durh|||dYn0|tj |d|j t tj dS)NrrrZ2P2ir) rCrrrr_astZASTrr r/r)rr)rrrrr6tbrrrtest_pythontypess  zSizeofTest.test_pythontypescCst}||j||jdd}tj|dt}||j|||d|||jd||dddd}tj|dt}||j|||d|||j|||d|tj|t}||j||jdS)NcWsdSr!rr`rrrrLz0SizeofTest.test_asyncgen_hooks..) firstiterrrAcWsdSr!rr9rrrr:rL) finalizer)r get_asyncgen_hooksrXr;r<set_asyncgen_hooksry)roldr;Zhooksr<Zcurrrrtest_asyncgen_hookss*      zSizeofTest.test_asyncgen_hookscCs6td}td|\}}}||d||ddS)Nz import sys class MyStderr: def write(self, s): sys.stderr = None sys.stderr = MyStderr() 1/0 rKrL)rrrr rrrr/test_changing_sys_stderr_and_removing_references  z:SizeofTest.test_changing_sys_stderr_and_removing_reference)r(r)r*rrCrrrrrr)r,r5r8r@rA __classcell__rrr'rr,s   r__main__)rCrrqrrr rRr{r`rr?rrr rZ test.supportrrr9rZTestCaserr+rGrrrr(mainrrrrsF /(<