
    h                         % S r SSKrSSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSK
JrJr  \R                  " 5       q " S S5      r0 r\	\\4   \S	'   S
 rS r " S S\5      rS rS rSS jrg)z&
*Real* reloading support for Python.
    N)reload)
ModuleType)Dict)logreflectc                   .    \ rS rSrSr\rS rS rS rSr	g)	Sensitive   z
A utility mixin that's sensitive to rebuilds.

This is a mixin for classes (usually those which represent collections of
callbacks) to make sure that their code is up-to-date before running.
c                 ,    U R                   [         :  nU$ NlastRebuild)selfyns     ]/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/python/rebuild.pyneedRebuildUpdateSensitive.needRebuildUpdate$   s    +	    c                 8    [         R                   " 5       U l        g r   )timer   r   s    r   rebuildUpToDateSensitive.rebuildUpToDate(   s    99;r   c                 H   [        U5      nU[        R                  :X  a  [        U5      $ U[        R                  :X  aM  UR
                  c   [        UR                  UR                  5      $ [        UR
                  UR                  5      $ [        R                  " S5        U$ )z
Get the latest version of an object.

This can handle just about anything callable; instances, functions,
methods, and classes.
zwarning returning anObject!)typetypesFunctionTypelatestFunction
MethodType__self__getattrim_class__name__r   msg)r   anObjectts      r   latestVersionOfSensitive.latestVersionOf+   s     N"""!(++%"""  (x00(2C2CDDx00(2C2CDDGG12Or   r   N)
r#   
__module____qualname____firstlineno____doc__r   r   r   r'   __static_attributes__ r   r   r	   r	      s     K'r   r	   _modDictIDMapc                     [        U R                  5      n[        R                  U5      nUc  U $ [	        X R
                  5      $ )z'
Get the latest version of a function.
)id__globals__r/   getr!   r#   )oldFuncdictIDmodules      r   r   r   B   s?     ##$Fv&F~6++,,r   c                    [         R                  " U R                  5      n[        XR                  5      nUR
                   Vs/ s H  n[        U5      PM     nnUR                  S:X  a  U$  [        U5      Ul        U$ s  snf ! [         a>    [        U5      nU" UR                  [        U5      [        UR                  5      5      s $ f = f)z$
Get the latest version of a class.
builtins)r   namedModuler)   r!   r#   	__bases__latestClasstuple	TypeErrorr   dict__dict__)oldClassr6   newClassbasenewBasesctors         r   r;   r;   O   s       !4!45Fv001H.6.@.@A.@dD!.@HAj(Q"8_ B  QH~H%%uXX=N=N8OPPQs   B .B ACCc                       \ rS rSrSrSrg)RebuildErrord   zL
Exception raised when trying to rebuild a class whereas it's not possible.
r.   N)r#   r)   r*   r+   r,   r-   r.   r   r   rF   rF   d   s    r   rF   c                 8    [        U R                  5      U l        g)z$
Updates an instance to be current.
N)r;   	__class__r   s    r   updateInstancerJ   j   s     !0DNr   c                     US:X  a  [        S5      e[        U 5        [        R                  " S[        R
                  " U R                  5       SU S35        [        X5      nU$ )z4
A getattr method to cause a class to be refreshed.
__del__zWithout this, Python segfaults.z(rebuilding stale z instance (z)))AttributeErrorrJ   r   r$   r   qualrI   r!   )r   nameresults      r   __injectedgetattr__rQ   q   sY     y>??4GG dnn!= >k$rRST FMr   c                    [         R                   " 5       q[        U S5      (       a  U R                  (       d  [	        S5      eU(       a-  [
        R                  " S[        U R                  5       S35        SSK	J
n  SUl        U R                  nU [        [        U5      '   0 n0 n0 n0 nU(       a-  [
        R                  " S[        U R                  5       S	35        UR                  5        GH  u  p[!        [#        U	5      [$        R&                  5      (       ag  U	R(                  U R                  L aL  S
Xi'   U(       a?  [
        R*                  R-                  S5        [
        R*                  R/                  5         M  M  M  [1        U	["        5      (       d  M  U	R2                  U R                  :X  d  M  S
XI'   U(       d  M  [
        R*                  R-                  S5        [
        R*                  R/                  5         GM     UR5                  U5        UR5                  U5        UR6                  n
UR9                  5       nUR9                  5       nUR9                  5       nU(       aC  [
        R                  " S5        [
        R                  " S[        U R                  5       S35        [;        U 5        [<        R>                  " 5         U(       a-  [
        R                  " S[        U R                  5       S	35        U H  n[A        XR                  5      UL a0  [
        R                  " S[B        RD                  " U5       S35        MK  U(       a=  [
        R*                  R-                  S5        [
        R*                  R/                  5         SUl#        UR                  RI                  5         [J        Ul&        U R                  Ul        M     U(       a  SSK'nU H  n[A        XR                  5      nXL a;  [
        R                  " SRQ                  [B        RD                  " U5      5      5        MW  WRS                  U5       H  n[A        USS5      UL d  M  Xl*        M     M     U(       aC  [
        R                  " S5        [
        R                  " S[        U R                  5       S	35        Sn[V        RX                  R                  5        GH5  u  nnUS
-   nUU :X  d  Uc  M  [        US5      (       d  M*  [        US5      (       a  M=  SnUR                  R                  5        H~  u  p [[        U	5        U
" U	5      (       d  M   U(       a=  [
        R*                  R-                  S5        [
        R*                  R/                  5         [_        U	5      nS
n[a        UUU5        M     U(       d  M  U(       a  M  US-  S:X  d  M  [
        R*                  R-                  S5        [
        R*                  R/                  5         GM8     SUl        U(       aC  [
        R                  " S5        [
        R                  " S[        U R                  5       S35        U $ ! [\         a     GMB  f = f)zG
Reload a module and do as much as possible to replace its references.
ALLOW_TWISTED_REBUILDzI am not allowed to be rebuilt.zRebuilding z...r   )
componentsTz  (scanning z):    fo z  (reload   )z  (cleaning zWARNING: class z not replaced by reload!xr.   Nz-WARNING: new-class {} not replaced by reload!rI   z  (fixing   __file__
__bundle__
   .Fz   Rebuilt )1r   r   hasattrrS   RuntimeErrorr   r$   strr#   twisted.pythonrT   ALLOW_DUPLICATESr?   r/   r1   items
issubclassr   r   r   r2   logfilewriteflush
isinstancer)   update__contains__keysr   	linecache
clearcacher!   r   rN   r:   clearrQ   __getattr__gcformatget_referrersrI   sysmoduleshash	Exceptionr   setattr)r6   doLogrT   d
newclassesclasses	functionsvalueskvfromOldModuleclazzrq   nclassgarmodcountmkmodchangednvs                        r   rebuildr   }   s   
 ))+Kv.//++@AA+c&//23378 *"&JA!M"Q%JGIF,s6??34C89	d1gu1122}}/ 	KK%%c*KK%%'  0
 4  ||v. !
5KK%%c*KK%%'  MM'
MM)''M"JllnG I,s6??34A67 6N,s6??34C896>>*e3GGogll5&9%::RST!!#&!!# EONN  " 3E%E  V__-<GG?FFLL( %%f-1k40F:"$K .  ,s6??34C89H;;$$&Ca<&=CKsJ''3%% LL&&(DAQ QKK%%c*KK%%'#A&Q# ) 5x"}&:KKc"KK? 'B #(J+c&//23156M#  s   4Y""
Y10Y1)rU   )r,   rm   rt   r   r   	importlibr   r   typingr   rb   r   r   r   r	   r/   int__annotations__r   r;   rw   rF   rJ   rQ   r   r.   r   r   <module>r      sz           (iik" "J (*tCO$ )
-Q*9 1	}r   