zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
U
Z±dQBã@sðddlZddlZddlmZddlZddlmZejdkrPddlm    Z    m
Z
m Z n ddl m Z dd„Z ejd    d
Gd d „d ƒƒZGd d„de    ƒZGdd„dee
ƒZde_de_z ddlZWnek
rÐdZYnXd    Zerädd„Zn*ddlZddlZGdd„dejƒZdd„Zdd„ZdejkrpddlZe ¡Zedk    rpej dkrXej!de"dnd'dd„Z#e $e    fe#¡ejdkrìe%ej&d dƒd!krìdd"l'm(Z(ddl)Z)dd#lm*Z*ej&e)j+ksÂt,‚d$d%„Z-e(d&ƒZ.e.j/ 0ej/¡e-e._1e.e)_dS)(éN)ÚSequence)Úwarn_deprecated)éé )ÚBaseExceptionGroupÚExceptionGroupÚprint_exception©rcs>‡‡fdd„‰‡fdd„‰tƒ}ˆ||ƒ}ˆd||ƒŠŠ|S)Ncs”t|tƒrng}d}|jD],}ˆ||ƒ}||k    r2d}|dk    r| |¡q|sNdS|rZt|ƒS| t|ƒ¡|Sn"ˆ|ƒ}|dk    rŒ||k    rŒ||_|SdS©NFT)Ú
isinstanceÚ
MultiErrorÚ
exceptionsÚappendÚaddÚidÚ __context__)ÚexcÚ    preservedZnew_exceptionsÚchangedÚ    child_excZ new_child_excÚnew_exc)Ú filter_treeÚhandler©úMd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\trio/_core/_multierror.pyrNs&
 
 
 z!_filter_impl.<locals>.filter_treecsPt|ƒ|krdSt||jƒ}t|tƒrF|jD]}ˆ|||ƒq,d|_n||_dS©N)rÚ    concat_tbÚ __traceback__r r r )ÚtbrrÚnew_tbr)Ú push_tb_downrrr fs  
 
z"_filter_impl.<locals>.push_tb_down)Úset)rÚroot_excrZ new_root_excr)rrr rÚ _filter_impls; 
 r#T)Úfrozenc@s$eZdZe ¡Zdd„Zdd„ZdS)ÚMultiErrorCatchercCsdSrr©ÚselfrrrÚ    __enter__ƒszMultiErrorCatcher.__enter__c    Csh|dk    rdt|j|ƒ}||kr dS|dkr,dS|j}z|‚W5t ¡\}}}||ksVt‚||_~~~XdSr
)r#Ú_handlerrÚsysÚexc_infoÚAssertionError)r'ÚetyperrZ filtered_excZ old_contextÚ_ÚvaluerrrÚ__exit__†s  zMultiErrorCatcher.__exit__N)Ú__name__Ú
__module__Ú __qualname__ÚattrÚibr)r(r0rrrrr%sr%csheZdZdZddœ‡fdd„
Zddœ‡fdd„
Zdd    „Zd
d „Zd d „Ze    dd„ƒZ
e    dd„ƒZ ‡Z S)r a^An exception that contains other exceptions; also known as an
    "inception".
 
    It's main use is to represent the situation when multiple child tasks all
    raise errors "in parallel".
 
    Args:
      exceptions (list): The exceptions
 
    Returns:
      If ``len(exceptions) == 1``, returns that exception. This means that a
      call to ``MultiError(...)`` is not guaranteed to return a
      :exc:`MultiError` object!
 
      Otherwise, returns a new :exc:`MultiError` object.
 
    Raises:
      TypeError: if any of the passed in objects are not instances of
          :exc:`BaseException`.
 
    T©Ú    _collapsecs0||_|rt|ddƒdk    rdStƒ d|¡dS)Nr úmultiple tasks failed)ÚcollapseÚgetattrÚsuperÚ__init__)r'r r7©Ú    __class__rrr<·szMultiError.__init__cslt|ƒ}|D]}t|tƒs td|›ƒ‚q |rBt|ƒdkrB|dStdd„|DƒƒrXt}tƒ |d|¡SdS)Nz"Expected an exception object, not ércss|]}t|tƒVqdSr)r Ú    Exception©Ú.0rrrrÚ    <genexpr>Ósz%MultiError.__new__.<locals>.<genexpr>r8)    Úlistr Ú BaseExceptionÚ    TypeErrorÚlenÚallÚNonBaseMultiErrorr;Ú__new__)Úclsr r7rr=rrrJÂs
zMultiError.__new__cCsd dd„|jDƒ¡S)Nz, css|]}t|ƒVqdSr)ÚreprrArrrrCÙsz%MultiError.__str__.<locals>.<genexpr>)Újoinr r&rrrÚ__str__ØszMultiError.__str__cCs
d |¡S)Nz<MultiError: {}>)Úformatr&rrrÚ__repr__ÛszMultiError.__repr__cCst|dd}|j|_|S)NFr6)r r9)r'Z_MultiError__excsrrrrÚderiveÞs zMultiError.derivecCstdddddt||ƒS)uLApply the given ``handler`` to all the exceptions in ``root_exc``.
 
        Args:
          handler: A callable that takes an atomic (non-MultiError) exception
              as input, and returns either a new exception object or None.
          root_exc: An exception, often (though not necessarily) a
              :exc:`MultiError`.
 
        Returns:
          A new exception object in which each component exception ``exc`` has
          been replaced by the result of running ``handler(exc)`` â€“ or, if
          ``handler`` returned None for all the inputs, returns None.
 
        zMultiError.filter()ú0.22.0zBaseExceptionGroup.split()飩ZinsteadÚissue)rr#)rKrr"rrrÚfilteråsüzMultiError.filtercCstdddddt|ƒS)z®Return a context manager that catches and re-throws exceptions
        after running :meth:`filter` on them.
 
        Args:
          handler: as for :meth:`filter`
 
        úMultiError.catchrRz!except* or exceptiongroup.catch()rSrT)rr%)rKrrrrÚcatchýs    ürW) r1r2r3Ú__doc__r<rJrNrPrQÚ classmethodrVrXÚ __classcell__rrr=rr  s 
r c@s eZdZdS)rIN)r1r2r3rrrrrIsrIZtrioFcs‡fdd„}t |t|ƒ|¡S)Ncs$|jdkr|jddkrˆS| ¡S)N)Ú__getattribute__Ú __getattr__rÚtb_next)ÚopnameÚargsZdelegate)Z    operation©r^rrÚ
controller5s
zcopy_tb.<locals>.controller)ÚtputilZ
make_proxyÚtype)Úbase_tbr^rbrrarÚcopy_tb4s rfc@sBeZdZdejeƒ ¡fdejfdejfdejfdejfgZ    dS)Ú
CTracebackZ PyObject_HEADr^Útb_frameÚtb_lastiÚ    tb_linenoN)
r1r2r3ÚctypesÚc_byteÚobjectÚ
__sizeof__Úc_void_pÚc_intÚ_fields_rrrrrgPs ûrgc
CsÄzt‚Wn(tk
r0}z
|j}W5d}~XYnXt t|ƒ¡}|jdksNt‚|dk    rjt |¡t|ƒ|_|j    dk    sxt‚t |j    ¡|j    }t|j    ƒ|_    t 
|¡|j |_ |j |_ z|W¢S~~XdSr) Ú
ValueErrorrrgÚ from_addressrr^r,Ú_ctypesÚ    Py_INCREFrhÚ    Py_DECREFrirj)rer^rrZc_new_tbZ old_tb_framerrrrfYs&
 
 
cCsDg}|}|dk    r"| |¡|j}q|}t|ƒD]}t||d}q.|S)Nra)rr^Úreversedrf)ÚheadÚtailZhead_tbsÚpointerZ current_headZhead_tbrrrrs
 rÚIPythonrz·IPython detected, but you already have a custom exception handler installed. I'll skip installing Trio's custom handler, but this means exception groups will not show full tracebacks.)ÚcategorycCs t|ƒdSrr    )r'r-r/rZ    tb_offsetrrrÚtrio_show_tracebackŸsr}r1Úapport_excepthook)Ú
ModuleType)Úformat_exceptioncCstj d t|||ƒ¡¡dS)NÚ)r*ÚstderrÚwriterMr€)r-r/rrrrÚreplacement_excepthook¾sr„Z trio_fake_sys)N)2r*ÚwarningsÚtypingrr4Ztrio._deprecaterÚ version_infoZexceptiongrouprrrÚ    tracebackr#Úsr%r rIr2rcÚ ImportErrorZ have_tproxyrfrkrtÚ    StructurergrÚmodulesr{Z get_ipythonÚipZcustom_exceptionsÚwarnÚRuntimeWarningr}Zset_custom_excr:Ú
excepthookÚtypesrZapport_python_hookr€r~r,r„Zfake_sysÚ__dict__ÚupdateÚ__excepthook__rrrrÚ<module>sd  
 l
 p 
 
    & 
 û    
ÿþ