
    sir;                        S r SSKJr  SSKrSSKrSSKJrJr  SSKJ	r	  SSK
Jr  SSKJrJr  SS	KJr  \(       a  SS
KJr  SSKJr  SSK
JrJr  \" S5      r\	" \5      r " S S5      rSS jrg)z#Error handling and error reporting.    )annotationsN)cached_propertypartial	getLogger)TYPE_CHECKING   )ensure_text_typeon_win)
deprecated)Callable)TracebackType)AnyTypeVarTc                     \ rS rSrSS jrSS jr\S 5       r\S 5       r\\	" SS5      S 5       5       r
SS	 jr      SS
 jr      SS jr      SS jr      SS jr      SS jrSS jrSS jr\SS j5       r\	" SS5      SS j5       r\	" SS5      SS j5       r\	" SS5      SS j5       r\	" SS5      S S j5       rSrg)!ExceptionHandler   c                t     U" U0 UD6$ !   [         R                  " 5       u  pEnU R                  XV5      s $ = fN)sysexc_infohandle_exception)selffuncargskwargs_exc_valexc_tbs          7lib/python3.13/site-packages/conda/exception_handler.py__call__ExceptionHandler.__call__   s?    	:(((	:!$A((99s   
 +7c                v    SSK Jn  SSKJn  U" 5         U" S5      R	                  SR                  U5      5        g )Nr   r   r	   )init_loggerszconda.stderr
)loggingr   cli.mainr%   infojoin)r   contentr   r%   s       r!   	write_outExceptionHandler.write_out#   s)    %*.!&&tyy'9:    c                >    SSK Jn  UR                  UR                  4$ Nr	   context)base.contextr2   remote_connect_timeout_secsremote_read_timeout_secsr   r2   s     r!   http_timeoutExceptionHandler.http_timeout+   s    )22G4T4TTTr.   c                &    SSK Jn  UR                  $ r0   )r3   r2   
user_agentr6   s     r!   r:   ExceptionHandler.user_agent1   s    )!!!r.   z26.9z27.3c                &    SSK Jn  UR                  $ r0   )r3   r2   error_upload_urlr6   s     r!   r=   !ExceptionHandler.error_upload_url7   s     	*'''r.   c                >   SSK Jn  SSKJnJnJn  [        X5      (       a3  UR                  (       a  U R                  X5      $ U R                  X5      $ [        U[        5      (       a)  [        USS 5      U:X  a  U R                  U" U5      U5      $ [        U[        5      (       a  U R                  U" U5      U5      $ [        U[        5      (       a  U R                  U" S5      U5        g[        U[        5      (       a  UR                   $ U R#                  X5      $ )Nr   )ENOSPCr	   )
CondaErrorCondaMemoryErrorNoSpaceLeftErrorerrnoKeyboardInterrupt)rD   r@   
exceptionsrA   rB   rC   
isinstance
reportable'handle_reportable_application_exceptionhandle_application_exceptionEnvironmentErrorgetattrMemoryErrorrE   _print_conda_exception
SystemExitcodehandle_unexpected_exception)r   r   r    r@   rA   rB   rC   s          r!   r   !ExceptionHandler.handle_exceptionA   s     	
 	
 g**!!CCGTT88IIg/00w.&888$W-v  g{++445Eg5NPVWWg011''
3F(GPgz**<<//@@r.   c                <    U R                  X5        UR                  $ r   )rN   return_code)r   r   r    s      r!   rJ   -ExceptionHandler.handle_application_exception]   s     	##G4"""r.   c                     SSK Jn  U" X5        g )Nr	   )print_conda_exception)rF   rW   )r   r   r    rW   s       r!   rN   'ExceptionHandler._print_conda_exceptionc   s    
 	6g.r.   c                n    U R                  X5      nU R                  U5        [        USS 5      nUb  U$ S$ )NrT   r	   )get_error_reportprint_unexpected_error_reportrL   )r   r   r    error_reportrcs        r!   rQ   ,ExceptionHandler.handle_unexpected_exceptionl   s?     ,,W=**<8WmT2^r**r.   c                    U R                  X5      nSSKJn  UR                  (       a  UR	                  UR                  5       5        U R                  U5        UR                  $ r0   )rZ   r3   r2   jsonupdatedump_mapprint_expected_error_reportrT   )r   r   r    r\   r2   s        r!   rI   8ExceptionHandler.handle_reportable_application_exceptiont   sO     ,,W=)<< 0 0 23((6"""r.   c                   SSK JnJn  SR                  S [        R
                   5       5      n0 nSU;  a   SSKJn  U" 5       n[        U5      UR                  R                  [        UR                  5      UU" X5      US.n
[        X5      (       a  UR                  5       U
S	'   U
$ ! [         aH  nU" 5       n	[        U5      UR                  R                  [        UR                  5      U	S.n S nANS nAff = f)
Nr	   )rA   _format_exc c              3  8   #    U  H  n[        U5      v   M     g 7fr   )r
   ).0ss     r!   	<genexpr>4ExceptionHandler.get_error_report.<locals>.<genexpr>   s     A1+A..s   z info)get_info_dict)errorexception_nameexception_type	traceback)rn   ro   rp   commandrq   
conda_infoconda_error_components)rF   rA   rf   r*   r   argvcli.main_inform   	Exceptionrepr	__class____name__strrG   rb   )r   r   r    rA   rf   rr   	info_dictrm   info_einfo_tracebackr\   s              r!   rZ   !ExceptionHandler.get_error_report   s    
 	8((AAA	'!8)O	 ']%//88!'"3"34$W5#
 g**5<5E5E5GL12+  !,!&\&,&6&6&?&?&)'*;*;&<!/		s   B) )
C;3>C66C;c                   SSK Jn  UR                  (       a  SSKJn  U" U5        g / nUR                  S5        UR                  S5        UR                  S5        UR                  S US   R                  5        5       5        UR                  S5        UR                  SR                  US	   5      5        UR                  S5        US
   (       a=  SSK	J
nJn   UR                  U" US
   5      5        UR                  U" US
   5      5        UR                  / SQ5        U R                  " U6   g ! [         aC  n[        R                  SUSS9  UR                  S5        UR                  U< 5         S nANkS nAff = f)Nr	   r1   stdout_json <# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<c              3  ,   #    U  H
  nS U-   v   M     g7f)z    N )ri   lines     r!   rk   AExceptionHandler.print_unexpected_error_report.<locals>.<genexpr>   s      #*P$*Ps   rq   `$ {}`rr   rs   get_env_vars_strget_main_info_str%rTr   $conda info could not be constructed.)r   zFAn unexpected error has occurred. Conda has prepared the above report.zEIf you suspect this error is being caused by a malfunctioning plugin,z;consider using the --no-plugins option to turn off plugins.r   z-Example: conda --no-plugins install <package>r   zGAlternatively, you can set the CONDA_NO_PLUGINS environment variable onz<the command line to run the command without plugins enabled.r   z6Example: CONDA_NO_PLUGINS=true conda install <package>r   )r3   r2   r`   
cli.commonr   appendextend
splitlinesformatrv   r   r   rw   logwarningr,   r   r\   r2   r   message_builderr   r   es           r!   r[   .ExceptionHandler.print_unexpected_error_report   s[   )<</% O""2&""N ""2&"" #*6{*C*N*N*P#  ""2&""8??<	3J#KL""2&L)N	5#**+;L<V+WX#**),|*DE """ NNO,+ ! 5KKa$K7#**+QR#**aU445s   4D4 4
F>9E<<Fc                ~   SSK Jn  UR                  (       a  SSKJn  U" U5        g / nUR                  S5        UR                  S5        UR                  S5        UR                  SR                  US   5      5        UR                  S5        US   (       a=  SS	KJnJ	n   UR                  U" US   5      5        UR                  U" US   5      5        UR                  S5        UR                  S5        UR                  S5        UR                  US   R                  5       5        UR                  S5        UR                  S5        UR                  S5        U R                  " U6   g ! [         aC  n[        R                  S
USS9  UR                  S5        UR                  U< 5         S nANS nAff = f)Nr	   r1   r   r   r   r   rr   rs   r   r   Tr   r   z=V V V V V V V V V V V V V V V V V V V V V V V V V V V V V V Vrn   zQA reportable application error has occurred. Conda has prepared the above report.)r3   r2   r`   r   r   r   r   rv   r   r   rw   r   r   r   r   r,   r   s           r!   rc   ,ExceptionHandler.print_expected_error_report   s   )<</% O""2&""N ""2&""8??<	3J#KL""2&L)N	5#**+;L<V+WX#**),|*DE ""2&""O ""2&""<#8#C#C#EF""2&""c ""2&NNO,# ! 5KKa$K7#**+QR#**aU445s   #4E/ /
F<99F77F<c                     [         R                  " S5      =(       d    [        $ ! [         a   n[        R                  SU5         S nAgS nAff = f)Nr   r   T)osisattyr   rw   r   debug)r   r   s     r!   _isattyExceptionHandler._isatty  s;    	99Q<)6) 	IIdA	s   "% 
AA

Ac                   SSK Jn  SnUR                  SL a  SnOUR                  SL d  UR                  (       a  SnOsUR                  (       d"  UR
                  (       d  U R                  (       d.  [        UR                  (       + =(       a    UR                  5      nOU R                  5       nSnU(       a  U R                  U5        U(       a  U R                  U5        gg)z4Determine whether or not to upload the error report.r	   r1   FTN)r3   r2   report_errors
always_yesr`   quietr   booloffline_ask_upload_execute_upload_post_upload)r   r\   r2   post_upload	do_uploads        r!   _uploadExceptionHandler._upload  s     	*  E)I""d*g.@.@I\\W]]$,,0GW5G5GHI ((*IK   .i( r.   c                    SSK Jn  SSKJn   U" S[	        [
        S5      5      nU=(       a    U" U5      $ ! [         a   n[        R                  SU5         S nAgS nAff = f)Nr	   )boolify)timeout(   zIf submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers? [y/N]: r   F)	auxlib.type_coercionr   	common.ior   r   inputrw   r   r   )r   r   r   r   r   s        r!   r   ExceptionHandler._ask_upload2  s_    
 	2&		I 3!33 	IIdA	s   '6 
A  AA c                   SS K nSSKJn  SU R                  0nU R                  nUR                  5       n[        S U 5       5      (       a  SOSUS'   S	[        U5      ;   a  SOSUS
'   UR                  USS9S-   nUR                  [        U5      S5      nS n SS K
n	Sn
U R                  nU	R                  XXWSS9nUR                  5         UR                  S;   a  UR                  R!                  S5      (       a}  UR                  S   nU	R                  UUUUSS9nUR                  5         U
S-  n
U
S:  a  SSKJn  U" S5      eUR                  S;   a"  UR                  R!                  S5      (       a  M}  [&        R)                  SU=(       a    UR                  5         U(       a#  UR.                  (       a  U R1                  S5        g U R1                  S5        U(       a1  UR                  (       a  U R1                  SUR                   35        g g g ! [*         a   n[&        R-                  SU5         S nANS nAff = f! [*         a!  n[&        R)                  U< 5         S nAg S nAff = f)Nr   r	   )r`   z
User-Agentc              3  >   #    U  H  n[        U5      S :  v   M     g7f)   N)ord)ri   cs     r!   rk   3ExceptionHandler._execute_upload.<locals>.<genexpr>Y  s     7hAhs   TFis_asciirg   
has_spaces)	sort_keysr&   USERNAME_REMOVED)headersr   dataallow_redirects)i-  i.  Location   )rA   zRedirect limit exceededzupload response status: %sr   zUpload successful.zUpload did not complete.z HTTP )getpasscommon.serializer`   r:   r7   getuserallr{   dumpsreplacerequestsr=   postraise_for_statusstatus_coder   getr   rA   r   r   rw   r)   okr,   )r   r\   r   r`   r   _timeoutusernamer   responser   redirect_counterurlrA   r   s                 r!   r    ExceptionHandler._execute_uploadJ  sO   
 	* $//
 $$??$7h777DU 	Z  .1CM-ATu\"zz,$z7$>||CM+=>	  ''C}}hSX % H %%'&&*49I9I9M9M: : &&z2#==#$$) )  ))+ A% #b(,$%>??! &&*49I9I9M9M: :" II2H4UAUAUV	 HKK349: 4 4NNVH,@,@+A#BC !58  	HHT1	  	 II	 s>   CH :)H $)I AI 
I"H==I
I0I++I0c           	         USL a  U R                  SSSSSSS5        g Uc  U R                  SSS5        g U R                  SSSS	S5        g )
NTr   z'Thank you for helping to improve conda.zAOpt-in to always sending reports (and not see this message again)z
by runningz+    $ conda config --set report_errors truez Timeout reached. No report sent.z+No report sent. To permanently opt-out, usez,    $ conda config --set report_errors false)r,   )r   r   s     r!   r   ExceptionHandler._post_upload  sg    
 NN9S= NN2 NN=>r.   r   Nr   zCallable[..., T]returnzT | int)r+   r{   r   None)r   BaseExceptionr    r   r   int)r   r   r    r   r   r   )r   r   r    r   r   dict[str, str])r\   r   r   r   )r   r   )r\   zdict[str, Any]r   r   )r   r   r   r   )rz   
__module____qualname____firstlineno__r"   r,   propertyr7   r:   r   r=   r   rJ   rN   rQ   rI   rZ   r[   rc   r   r   r   r   r   r   __static_attributes__r   r.   r!   r   r      s   :; U U
 " "
 (	 
(
A8#$#.;#	#// / 
	/+$+.;+	+	#$	#.;	#		#%% % 
	%N2-h*-X   )	)@ 	( 9 	9 v 	r.   r   c                2    [        5       nU" U /UQ70 UD6nU$ r   )r   )r   r   r   exception_handlerreturn_values        r!   conda_exception_handlerr     s%    (*$T;D;F;Lr.   r   )__doc__
__future__r   r   r   	functoolsr   r   r'   r   typingr   common.compatr
   r   deprecationsr   collections.abcr   typesr   r   r   r   rz   r   r   r   r   r.   r!   <module>r      sS    * " 	 
 .    3 $(##AN Nbr.   