
    <Bh:                        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  \(       a  SS	KJr  SS
K
Jr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)TracebackType)AnyCallableTypeVarTc                      \ rS rSrSS jrSS jr\S 5       r\S 5       r\S 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 jrSS jrSS jrSS j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.contextr1   remote_connect_timeout_secsremote_read_timeout_secsr   r1   s     r    http_timeoutExceptionHandler.http_timeout)   s    )22G4T4TTTr-   c                &    SSK Jn  UR                  $ r/   )r2   r1   
user_agentr5   s     r    r9   ExceptionHandler.user_agent/   s    )!!!r-   c                &    SSK Jn  UR                  $ r/   )r2   r1   error_upload_urlr5   s     r    r<   !ExceptionHandler.error_upload_url5   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)rC   r?   
exceptionsr@   rA   rB   
isinstance
reportable'handle_reportable_application_exceptionhandle_application_exceptionEnvironmentErrorgetattrMemoryErrorrD   _print_conda_exception
SystemExitcodehandle_unexpected_exception)r   r   r   r?   r@   rA   rB   s          r    r   !ExceptionHandler.handle_exception;   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   )rM   return_code)r   r   r   s      r    rI   -ExceptionHandler.handle_application_exceptionW   s     	##G4"""r-   c                     SSK Jn  U" X5        g )Nr	   )print_conda_exception)rE   rV   )r   r   r   rV   s       r    rM   'ExceptionHandler._print_conda_exception]   s    
 	6g.r-   c                    U R                  X5      nU R                  U5        U R                  U5        [        USS 5      nUb  U$ S$ )NrS   r	   )get_error_reportprint_unexpected_error_report_uploadrK   )r   r   r   error_reportrcs        r    rP   ,ExceptionHandler.handle_unexpected_exceptionf   sK     ,,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                  U5        UR                  $ r/   )	rY   r2   r1   jsonupdatedump_mapprint_expected_error_reportr[   rS   )r   r   r   r\   r1   s        r    rH   8ExceptionHandler.handle_reportable_application_exceptiono   s[     ,,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	   )r@   _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)rE   r@   rf   r)   r   argvcli.main_inform   	Exceptionrepr	__class____name__strrF   rb   )r   r   r   r@   rf   rr   	info_dictrm   info_einfo_tracebackr\   s              r    rY   !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:2>C55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	   r0   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   )r2   r1   r`   
cli.commonr   appendextend
splitlinesformatrv   r   r   rw   logwarningr+   r   r\   r1   r   message_builderr   r   es           r    rZ   .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   4D3 3
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	   r0   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.)r2   r1   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	   r0   FTN)r2   r1   report_errors
always_yesr`   quietr   booloffline_ask_upload_execute_upload_post_upload)r   r\   r1   post_upload	do_uploads        r    r[   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_upload*  s]    1&		I 3!33 	IIdA	s   '6 
A  AA c                   SS K n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US9S-   nUR                  [        U5      S5      nS n	 SS Kn
SnU R                  nU
R                  XXhS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	R0                  (       a  U R3                  S5        g U R3                  S5        U	(       a1  U	R                  (       a  U R3                  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	   )EntityEncoderz
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>J  s     7hAhs   TFis_asciirg   
has_spaces)	sort_keysclsr%   USERNAME_REMOVED)headersr   dataallow_redirects)i-  i.  Location   )r@   zRedirect limit exceededzupload response status: %sr   zUpload successful.zUpload did not complete.z HTTP )getpassr`   auxlib.entityr   r9   r6   getuserallr{   dumpsreplacerequestsr<   postraise_for_statusstatus_coder   getr   r@   r   r   rw   r(   okr+   )r   r\   r   r`   r   r   _timeoutusernamer   responser   redirect_counterurlr@   r   s                  r    r    ExceptionHandler._execute_upload>  sR   0 $//
 $$??$7h777DU 	Z  .1CM-ATu\"zz,$MzJTQ||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&II	
I4I//I4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_uploadz  se    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+   propertyr6   r9   r<   r   rI   rM   rP   rH   rY   rZ   rc   r   r   r[   r   r   r   __static_attributes__r   r-   r    r   r      s    :; U U
 " "
 ( (
A8#$#.;#	#// / 
	/+$+.;+	+
#$
#.;
#	
#%% % 
	%N2-h*-X  )@(: x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   typesr   r   r   r   r   rz   r   r   r   r   r-   r    <module>r      sP    * " 	 
 .    3#--A} }@r-   