
    xKgO                        d Z ddlZddlZddlZddlZddlZddlmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZmZmZmZ ddlmZ ddlmZmZmZ dd	lmZmZmZmZ dd
lm Z  ddl!m"Z# ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* ddl+Z+ G d de+jT                        Z, G d de+jT                        Z- G d de+jT                        Z. G d de+jT                        Z/ G d de'e+jT                        Z0 G d de'e*      Z1e2dk(  r e+jf                          yy)z"
Unspecified error handling tests
    N)jitnjittypes)errors)	structref)overload	intrinsicoverload_methodoverload_attribute)CompilerBase)TranslateByteCode	FixupArgsIRProcessing)NopythonTypeInferenceDeadCodeEliminationNoPythonBackendNativeLowering)PassManager)_err_reasons)skip_parfors_unsupportedoverride_configSerialMixinskip_unless_cffiskip_unless_scipyTestCasec                       e Zd Zd Zy)TestErrorHandlingBeforeLoweringc                     d }t         t        fD ]_  }| j                  t        j                        5 }  ||      d       d d d        d}| j                  |t        j                               a y # 1 sw Y   3xY w)Nc                     | dz   fd}|S )z return the closure    c                     | z   S N )xzs    b/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numba/tests/test_errorhandling.pyinnerzmTestErrorHandlingBeforeLowering.test_unsupported_make_function_return_inner_func.<locals>.func.<locals>.inner%   s    1u    r#   )r$   r'   r%   s     @r&   funcz^TestErrorHandlingBeforeLowering.test_unsupported_make_function_return_inner_func.<locals>.func!   s    AALr(   r    z%Cannot capture the non-constant value)r   r   assertRaisesr   TypingErrorassertInstr	exception)selfr)   pipelineraisesexpecteds        r&   0test_unsupported_make_function_return_inner_funczPTestErrorHandlingBeforeLowering.test_unsupported_make_function_return_inner_func    sg    	 T	H""6#5#56&q! 7 ?HMM(C(8(8$9: "66s   A33A<	N)__name__
__module____qualname__r3   r#   r(   r&   r   r      s    ;r(   r   c                       e Zd Zd Zy)TestUnsupportedReportingc                     t         d        }| j                  t        j                        5 } |        d d d        d}| j	                  |t        j                               y # 1 sw Y   1xY w)Nc                  2    t        j                  g d       y )N)r          )np
asanyarrayr#   r(   r&   r)   zFTestUnsupportedReporting.test_unsupported_numpy_function.<locals>.func5   s    MM'"r(   z4Use of unsupported NumPy function 'numpy.asanyarray'r   r*   r   r+   r,   r-   r.   )r/   r)   r1   r2   s       r&   test_unsupported_numpy_functionz8TestUnsupportedReporting.test_unsupported_numpy_function3   s`    		# 
	# v112fF 3 JhF$4$4 56	 32   A$$A-N)r4   r5   r6   r@   r#   r(   r&   r8   r8   1   s    
7r(   r8   c                   L    e Zd Zd Zd Zd Zd Zd Zd Ze	d        Z
d Zd	 Zy
)TestMiscErrorHandlingc                 x    t         d        }t        j                  dgt        j                        } ||       y )Nc                     d| z  S N
   r#   r$   s    r&   fnzHTestMiscErrorHandling.test_use_of_exception_for_flow_control.<locals>.fnG   s    q5Lr(   g      ?)dtype)r   r=   arrayfloat64)r/   rI   as      r&   &test_use_of_exception_for_flow_controlz<TestMiscErrorHandling.test_use_of_exception_for_flow_controlB   s5    
 
	 
	 HHcU,
1r(   c                     d }d }||fD ]L  }| j                  t              5 } |        d d d        | j                  dt        j                               N y # 1 sw Y   1xY w)Nc                      t        d      )Ntest_string	Exceptionr#   r(   r&   foo_commentedz_TestMiscErrorHandling.test_commented_func_definition_is_not_a_definition.<locals>.foo_commentedT       M**r(   c                      t        d      )z> def docstring containing def might match function definition!rQ   rR   r#   r(   r&   foo_docstringz_TestMiscErrorHandling.test_commented_func_definition_is_not_a_definition.<locals>.foo_docstringX   rU   r(   rQ   )r*   rS   r,   r-   r.   )r/   rT   rW   r)   r1   s        r&   2test_commented_func_definition_is_not_a_definitionzHTestMiscErrorHandling.test_commented_func_definition_is_not_a_definitionN   sY    	+	+ #M2D""9- . MM-V-=-=)>?	 3--s   AA$	c                 "    G d dt               }t        |      d        }| j                  t        j                        5 } |t        ddg             d d d        d}| j                  |t        j                               y # 1 sw Y   1xY w)Nc                       e Zd Zd Zy)FTestMiscErrorHandling.test_use_of_ir_unknown_loc.<locals>.TestPipelinec                 v   d}t        |      }|j                  t        d       |j                  t        d       |j                  t        d       |j                  t
        d       |j                  t        d       |j                  t        d       |j                  t        d       |j                          |gS )	Nbad_DCE_pipelinezanalyzing bytecodezfix up argszprocessing IRDCEznopython frontendznative loweringznopython mode backend)
r   add_passr   r   r   r   r   r   r   finalize)r/   namepms      r&   define_pipelineszWTestMiscErrorHandling.test_use_of_ir_unknown_loc.<locals>.TestPipeline.define_pipelinese   s    ) &-/CDI}5L/: /713FGN,=>O-DEtr(   N)r4   r5   r6   rc   r#   r(   r&   TestPipeliner[   d   s    r(   rd   )pipeline_classc                      y)Nr   r#   rM   s    r&   fz;TestMiscErrorHandling.test_use_of_ir_unknown_loc.<locals>.fu   s    r(   r    r;   z File "unknown location", line 0:)	r   r   r*   r   r+   iterr,   r-   r.   )r/   rd   rh   r1   r2   s        r&   test_use_of_ir_unknown_locz0TestMiscErrorHandling.test_use_of_ir_unknown_locb   s|    	< 	" 
\	*	 
+	 v112fdAa5kN 3 6hF$4$4 56	 32s   BBc                     | j                  t        j                        5 } |        d d d        ddg}|D ]'  }| j                  |t	        j
                               ) y # 1 sw Y   :xY w)NzThe use of az'in globals, is not supported as globals)r*   r   r+   r,   r-   r.   )r/   r)   r1   r2   exs        r&   check_write_to_globalsz,TestMiscErrorHandling.check_write_to_globals   s[    v112fF 3 #$MNBMM"c&"2"234 	 32s   A!!A*c                 D    ddl m} | j                  t        |             y )Nr   )global_reflected_write)"numba.tests.errorhandling_usecasesro   rm   r   )r/   ro   s     r&   *test_handling_of_write_to_reflected_globalz@TestMiscErrorHandling.test_handling_of_write_to_reflected_global   s    M##D)?$@Ar(   c                 D    ddl m} | j                  t        |             y )Nr   )global_dict_write)rp   rs   rm   r   )r/   rs   s     r&   +test_handling_of_write_to_typed_dict_globalzATestMiscErrorHandling.test_handling_of_write_to_typed_dict_global   s    H##D):$;<r(   c                     t        d      d        }| j                  t        j                        5 } |        d d d        d}| j	                  |t        j                               y # 1 sw Y   1xY w)NT)parallelc                  $    t        d      D ]  }  y rF   )prange)is    r&   foozPTestMiscErrorHandling.test_handling_forgotten_numba_internal_import.<locals>.foo   s    BZ  r(   zC'prange' looks like a Numba internal function, has it been importedr?   )r/   rz   r1   r2   s       r&   -test_handling_forgotten_numba_internal_importzCTestMiscErrorHandling.test_handling_forgotten_numba_internal_import   sd    	t		 
	 v112fE 3+hF$4$4 56 32s   A**A3c                    d }d}t        d      t        fD ]\  }| j                  t        j                        5 }  ||              d d d        | j                  |t        j                               ^ y # 1 sw Y   1xY w)Nc                  (    d t        d      D         y )Nc              3       K   | ]  }|  y wr"   r#   ).0r$   s     r&   	<genexpr>zdTestMiscErrorHandling.test_handling_unsupported_generator_expression.<locals>.foo.<locals>.<genexpr>   s     "	1Q	s   rG   )ranger#   r(   r&   rz   zQTestMiscErrorHandling.test_handling_unsupported_generator_expression.<locals>.foo   s    "b	"r(   z-The use of yield in a closure is unsupported.T)forceobj)r   r   r*   r   UnsupportedErrorr,   r-   r.   )r/   rz   r2   decr1   s        r&   .test_handling_unsupported_generator_expressionzDTestMiscErrorHandling.test_handling_unsupported_generator_expression   si    	# C%t+C""6#:#:;vC
 <MM(C(8(8$9: ,;;s   A88B	c                     t         d        }d}| j                  t        j                        5 } |        d d d        | j	                  |t        j                               y # 1 sw Y   /xY w)Nc                      t         S r"   rg   r#   r(   r&   rz   zCTestMiscErrorHandling.test_handling_undefined_variable.<locals>.foo   s    Hr(   z"NameError: name 'a' is not definedr?   )r/   rz   r2   r1   s       r&    test_handling_undefined_variablez6TestMiscErrorHandling.test_handling_undefined_variable   s]    		 
	 8v112fE 3hF$4$4 56 32s   A$$A-N)r4   r5   r6   rN   rX   rj   rm   rq   rt   r   r{   r   r   r#   r(   r&   rC   rC   @   s@    
@(7:5B= 7 7	;	7r(   rC   c                   n    e Zd Zd Zd Zed        Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zed        Zd Zy)TestErrorMessagesc                 l   dd t              fd       }t        fd       }| j                  t        j                        5 } |        d d d        t        j                        }| j                  t        d   j                         d   |       | j                  |       y # 1 sw Y   [xY w)Nspecific_reasonc                       y r"   r#   r#   r(   r&   rz   z2TestErrorMessages.test_specific_error.<locals>.foo       r(   c                  .    t        j                         r"   )r   NumbaValueError)given_reasons   r&   ol_fooz5TestErrorMessages.test_specific_error.<locals>.ol_foo   s    ((66r(   c                                y r"   r#   rz   s   r&   call_fooz7TestErrorMessages.test_specific_error.<locals>.call_foo       Er(   specific_errorr   )
r   r   r*   r   r+   r-   r.   r,   error_reasons
splitlines)r/   r   r   r1   excstrrz   r   s        @@r&   test_specific_errorz%TestErrorMessages.test_specific_error   s    (	 
#	7 
	7 
	 
	 v112fJ 3 V%%&m$45@@B1EvNlF+ 32s   B**B3c                    d t              d        }t        fd       }| j                  t        j                        5 } |        d d d        t        j                        }| j                  d|       y # 1 sw Y   1xY w)Nc                       y r"   r#   r#   r(   r&   rz   z2TestErrorMessages.test_no_match_error.<locals>.foo   r   r(   c                       y r"   r#   r#   r(   r&   r   z5TestErrorMessages.test_no_match_error.<locals>.ol_foo   s    r(   c                                y r"   r#   r   s   r&   r   z7TestErrorMessages.test_no_match_error.<locals>.call_foo   r   r(   zNo match)r   r   r*   r   r+   r-   r.   r,   )r/   r   r   r1   r   rz   s        @r&   test_no_match_errorz%TestErrorMessages.test_no_match_error   s    	 
#	 
	 
	 
	 v112fJ 3 V%%&j&)	 32s   A;;Bc                    t         d        }| j                  t        j                        5 } |        ddd       t	        j
                        }| j                  t        d   j                         d   |       t        j                  j                  ddd      }d| d	}| j                  |j                  |      |       y# 1 sw Y   xY w)
z Checks that the reported source location for an overload is the
        overload implementation source, not the actual function source from the
        target library.c                  B    t         j                  j                  d       y )Nchars)r=   linalgsvdr#   r(   r&   rz   zDTestErrorMessages.test_error_function_source_is_correct.<locals>.foo   s    IIMM'"r(   Nr   r   numbar=   z	linalg.pyz'Overload in function 'svd_impl': File: :)r   r*   r   r+   r-   r.   r,   r   r   ospathjoinformat)r/   rz   r1   r   expected_filer2   s         r&   %test_error_function_source_is_correctz7TestErrorMessages.test_error_function_source_is_correct   s     
	# 
	# v112fE 3 V%%&m$45@@B1EvNWdK@<]O1Mhoom4f= 32s   CCc                    t         d        }| j                  t        j                        5 } |        d d d        t	        j
                        }| j                  d|       | j                  d|       y # 1 sw Y   CxY w)Nc                      ddz   S )NrM   r    r#   r#   r(   r&   rz   z<TestErrorMessages.test_concrete_template_source.<locals>.foo   s    7Nr(   zOverload of function 'add'	No match.r   r*   r   r+   r-   r.   r,   r/   rz   r1   r   s       r&   test_concrete_template_sourcez/TestErrorMessages.test_concrete_template_source   sp    		 
	 v112fE 3 V%%&2F; 	k6* 32s   A66A?c                     t         d        }| j                  t        j                        5 } |        d d d        t	        j
                        }| j                  d|       y # 1 sw Y   1xY w)Nc                      t        d      S Nr    )lenr#   r(   r&   rz   z<TestErrorMessages.test_abstract_template_source.<locals>.foo  s    q6Mr(   zOverload of function 'len'r   r   s       r&   test_abstract_template_sourcez/TestErrorMessages.test_abstract_template_source  s`    		 
	 v112fE 3 V%%&2F;	 32rA   c                     t         d        }| j                  t        j                        5 } |        d d d        t	        j
                        }| j                  d|       y # 1 sw Y   1xY w)Nc                  ,    t        j                  d       S r"   )r=   angler#   r(   r&   rz   z<TestErrorMessages.test_callable_template_source.<locals>.foo  s    88D>!r(   z6No implementation of function Function(<function angler   r   s       r&   test_callable_template_sourcez/TestErrorMessages.test_callable_template_source  sc    		" 
	" v112fE 3 V%%&N		 32rA   c                    d t              d        }t        fd       }| j                  t        j                        5 } |        d d d        t        j                        }| j                  d|       t        j                  j                  ddd      }d| d	}| j                  |j                  |      |       | j                  d
|       y # 1 sw Y   xY w)Nc                      y r"   r#   rH   s    r&   barzDTestErrorMessages.test_overloadfunction_template_source.<locals>.bar  r   r(   c                      y r"   r#   rH   s    r&   ol_barzGTestErrorMessages.test_overloadfunction_template_source.<locals>.ol_bar       r(   c                        d      S r   r#   )r   s   r&   rz   zDTestErrorMessages.test_overloadfunction_template_source.<locals>.foo$  s    q6Mr(   z
<numerous>r   testsztest_errorhandling.pyz"Overload of function 'bar': File: r   r   )r   r   r*   r   r+   r-   r.   assertNotInr   r   r   r,   r   )r/   r   rz   r1   r   r   expected_olr   s          @r&   %test_overloadfunction_template_sourcez7TestErrorMessages.test_overloadfunction_template_source  s    	 
#	 
	 
	 
	 v112fE 3 V%%& 	v.Wg%<>:=/Kk((7@k6* 32s   CCc                    ddt         fd       t        fd       }| j                  t        j                        5 } |        d d d        t        j                        }| j                  t        d   j                         d   |       | j                  |       | j                  |       | j                  d|       y # 1 sw Y   xY w)Nzx must be literalzarray.ndim must be 1c                     t        |t        j                        st        j                        |j
                  dk7  rt        j                        t        j                  ||      }d }||fS )Nr    c                      y r"   r#   )contextbuilder	signatureargss       r&   codegenzSTestErrorMessages.test_intrinsic_template_source.<locals>.myintrin.<locals>.codegenD      r(   )
isinstancer   IntegerLiteralr   RequireLiteralValuendimr   intp)	typingctxr$   arrsigr   given_reason1given_reason2s        r&   myintrinzBTestErrorMessages.test_intrinsic_template_source.<locals>.myintrin:  s_    a!5!5600??xx1},,];;**Q$C<r(   c                  B    t        j                  d      }  d|        y )N)r;   r;   r    )r=   zeros)r   r   s    r&   call_intrinzETestErrorMessages.test_intrinsic_template_source.<locals>.call_intrinH  s    ((6"CQr(   r   r   zIntrinsic in function)
r	   r   r*   r   r+   r-   r.   r,   r   r   )r/   r   r1   r   r   r   r   s       @@@r&   test_intrinsic_template_sourcez0TestErrorMessages.test_intrinsic_template_source5  s    +.		  
	  
	 
	 v112fM 3 V%%&m$45@@B1EvNmV,mV,-v6 32s   C

Cc                     t        t        j                  d      d        }t        d        }| j	                  t
        j                        5 } |        d d d        t        j                        }| j                  d|       y # 1 sw Y   1xY w)N
isnonsensec                      y r"   r#   r/   s    r&   ol_unicode_isnonsensezTTestErrorMessages.test_overloadmethod_template_source.<locals>.ol_unicode_isnonsenseY  r   r(   c                  $    dj                          y Nabcr   r#   r(   r&   rz   zBTestErrorMessages.test_overloadmethod_template_source.<locals>.foo]  s    r(   ,Overload of function 'ol_unicode_isnonsense')
r
   r   UnicodeTyper   r*   r   r+   r-   r.   r,   r/   r   rz   r1   r   s        r&   #test_overloadmethod_template_sourcez5TestErrorMessages.test_overloadmethod_template_sourceV  s     
**L	9	 
:	 
	 
	 v112fE 3 V%%&DfM	 32   BBc                     t        t        j                  d      d        }t        d        }| j	                  t
        j                        5 } |        d d d        t        j                        }| j                  d|       y # 1 sw Y   1xY w)Nr   c                      y r"   r#   r   s    r&   r   zWTestErrorMessages.test_overloadattribute_template_source.<locals>.ol_unicode_isnonsensej  r   r(   c                      dj                    y r   r   r#   r(   r&   rz   zETestErrorMessages.test_overloadattribute_template_source.<locals>.foon  s    r(   r   )
r   r   r   r   r*   r   r+   r-   r.   r,   r   s        r&   &test_overloadattribute_template_sourcez8TestErrorMessages.test_overloadattribute_template_sourceg  s     
E--|	<	 
=	 
	 
	 v112fE 3 V%%&DfM	 32r   c                     ddl m t        fd       }| j                  t        j
                        5 } |        d d d        t        j                        }| j                  d|       y # 1 sw Y   1xY w)Nr   c_cosc                        d       y NrM   r#   r   s   r&   rz   zMTestErrorMessages.test_external_function_pointer_template_source.<locals>.foo{  s
    #Jr(   .Type Restricted Function in function 'unknown')	numba.tests.ctypes_usecasesr   r   r*   r   r+   r-   r.   r,   )r/   rz   r1   r   r   s       @r&   .test_external_function_pointer_template_sourcez@TestErrorMessages.test_external_function_pointer_template_sourcex  sd    5		 
	 v112fE 3 V%%&FO	 32s   A--A6c                 *   ddl m} |j                          |j                  t        fd       }| j                  t        j                        5 } |        d d d        t        j                        }| j                  d|       y # 1 sw Y   1xY w)Nr   )cffi_usecasesc                        d       y r   r#   )r)   s   r&   rz   zITestErrorMessages.test_cffi_function_pointer_template_source.<locals>.foo  s
    Ir(   r   )numba.testsr   initcffi_cosr   r*   r   r+   r-   r.   r,   )r/   modrz   r1   r   r)   s        @r&   *test_cffi_function_pointer_template_sourcez<TestErrorMessages.test_cffi_function_pointer_template_source  sv    4
||		 
	 v112fE 3 V%%&FO	 32s   B		Bc                    t         j                   G d dt        j                               } G d dt         j                        }t        j
                  ||ddg       | j                  t        j                        5 } |dd	       d d d        t        j                        }| j                  d
|       y # 1 sw Y   1xY w)Nc                       e Zd Zy);TestErrorMessages.test_missing_source.<locals>.ParticleTypeN)r4   r5   r6   r#   r(   r&   ParticleTyper    s    r(   r  c                       e Zd Zd Zy)7TestErrorMessages.test_missing_source.<locals>.Particlec                 B    t         j                  j                  | |      S r"   )r   StructRefProxy__new__)clsposmasss      r&   r
  z?TestErrorMessages.test_missing_source.<locals>.Particle.__new__  s     //77SAAr(   N)r4   r5   r6   r
  r#   r(   r&   Particler    s    Br(   r  r  r  r    r;   )r  r  z#missing a required argument: 'mass')r   registerr   	StructRefr	  define_proxyr*   r   r+   r-   r.   r,   )r/   r  r  r1   r   s        r&   test_missing_sourcez%TestErrorMessages.test_missing_source  s    				5?? 	 
		By// 	B
 	xvGv112f# 3 V%%&;VD	 32s   >B99CN)r4   r5   r6   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r#   r(   r&   r   r      sh    ,,*& > >$+ 
<+47BN"N"P P PEr(   r   c                       e Zd Zd Zy)"TestDeveloperSpecificErrorMessagesc                 $   d }t        dd      5  | j                  t        j                        5 } t	        d      |       d d d        d d d        t        j                        }| j                  d|       y # 1 sw Y   9xY w# 1 sw Y   =xY w)Nc                 &    | j                  d       y )N)maxrH   s    r&   rz   zPTestDeveloperSpecificErrorMessages.test_bound_function_error_string.<locals>.foo  s    EE"Ir(   DEVELOPER_MODEr    zvoid(int64[:,:])ztoo many positional arguments)r   r*   r   r+   r   r-   r.   r,   r   s       r&    test_bound_function_error_stringzCTestDeveloperSpecificErrorMessages.test_bound_function_error_string  sw    	 -q1""6#5#56&('(- 7 2 V%%&5v>	 76 21s"    BA:B:B	?BBN)r4   r5   r6   r  r#   r(   r&   r  r    s    
?r(   r  c                      e Zd ZdZd Zd Zd Zd Z  ej                  ddi      e      Z
 ej                  ddi      d	        Zd
 Z  ej                  ddi      e      Z  ej                  ddi      e      Zy)TestCapturedErrorHandlingzjChecks that the way errors are captured changes depending on the env
    var "NUMBA_CAPTURED_ERRORS".
    c           	         d t              d        }t        j                         5  t        j                  dt        j
                         dt        fdt        j                  ffD ]n  \  }}t        d|      5  | j                  |      5 }t        d      fd       }d d d        d	}| j                  |t        j                               d d d        p 	 d d d        y # 1 sw Y   DxY w# 1 sw Y   xY w# 1 sw Y   y xY w)
Nc                      y r"   r#   rH   s    r&   r   z=TestCapturedErrorHandling.test_error_in_overload.<locals>.bar  r   r(   c                 $    | j                    d }|S )Nc                      y r"   r#   rH   s    r&   implzNTestCapturedErrorHandling.test_error_in_overload.<locals>.ol_bar.<locals>.impl  r   r(   )some_invalid_attr)r$   r!  s     r&   r   z@TestCapturedErrorHandling.test_error_in_overload.<locals>.ol_bar  s    Kr(   ignore	new_style	old_styleCAPTURED_ERRORSvoid(int64)c                      |        y r"   r#   r$   r   s    r&   rz   z=TestCapturedErrorHandling.test_error_in_overload.<locals>.foo  s
    Fr(   z+object has no attribute 'some_invalid_attr')r   warningscatch_warningssimplefilterr   NumbaPendingDeprecationWarningAttributeErrorr+   r   r*   r   r,   r-   r.   )r/   r   style	err_classr1   rz   r2   r   s          @r&   test_error_in_overloadz0TestCapturedErrorHandling.test_error_in_overload  s    	 
#	 
	 $$&!!("("G"GI '2>%B&163E3E%F%H y$%6>**95m,# -# 6
  MHMM(C0@0@,AB ?>%H '& 65 ?> '&s<   AC<;C0C$	!/C0
C<$C-)C00C95C<<Dc                    d| d}t         j                  j                         }|j                  |       t	        j
                  t        j                  dd|gt        j                  t        j                  |      }|j                         \  }}|j                  dk7  r*t        d|j                  d|j                         d	      ||fS )
Nzif 1:
            z

            z-Wallz-c)stdoutstderrenvr   zprocess failed with code z: stderr follows

)r   environcopyupdate
subprocessPopensys
executablePIPEcommunicate
returncodeAssertionErrordecode)r/   runcoder5  codeproc_envpopenouterrs           r&   _run_in_separate_processz2TestCapturedErrorHandling._run_in_separate_process  s    I  ::??$  #..'4!F(2(2%-/
 $$&Sq  -2-=-=szz|"M N NCxr(   c                 j   ddl m} d}ddi}| j                  ||      \  }}| j                  ||j	                                ddi}| j                  ||      \  }}| j                  d|j	                                ddi}| j                  ||      \  }}| j                  d|j	                                y )	Nr   )_old_style_deprecation_msgz
        import numba
        NUMBA_CAPTURED_ERRORSr%   r-  r$  )numba.core.configrK  rI  r,   rB  r   )r/   rK  rD  r5  _outrH  s         r&   $test_old_style_deprecation_on_importz>TestCapturedErrorHandling.test_old_style_deprecation_on_import  s    @
 '411$<	c0#**,? '+11$<	c93::<H '411$<	c93::<Hr(   c                    t        j                  dt        j                         d t	              d        }| j                  t        j                        5 }| j                  t        j                        5  t        d      fd       }d d d        | j                  dt        |j                   d   j                               d d d        y # 1 sw Y   DxY w# 1 sw Y   y xY w)Nalwaysc                      y r"   r#   rH   s    r&   r   zBTestCapturedErrorHandling._test_old_style_deprecation.<locals>.bar  r   r(   c                     t        d      NzInvalid attributer.  rH   s    r&   r   zETestCapturedErrorHandling._test_old_style_deprecation.<locals>.ol_bar       !455r(   r'  c                      |        y r"   r#   r)  s    r&   rz   zBTestCapturedErrorHandling._test_old_style_deprecation.<locals>.foo  
    Fr(   zMCode using Numba extension API maybe depending on 'old_style' error-capturingr   )r*  r,  r   NumbaDeprecationWarningr   assertWarnsr*   r+   r   r,   r-   messager/   r   warnsrz   r   s       @r&   _test_old_style_deprecationz5TestCapturedErrorHandling._test_old_style_deprecation	  s    h(F(FG	 
#	6 
	6 f<<=""6#5#56m$ % 7
 MM"ENN1%--. >=66 >=s$    C9C:CC	CC%rL  r%  )envvarsc                    t        j                  dt        j                         d t	              d        }t        j
                  d      5 }| j                  t        j                        5  t        d      fd       }d d d        | j                  t        |      dd	
       d d d        y # 1 sw Y   /xY w# 1 sw Y   y xY w)NrR  c                      y r"   r#   rH   s    r&   r   zDTestCapturedErrorHandling.test_old_style_no_deprecation.<locals>.bar,  r   r(   c                 ,    t        j                  d      rU  )r   r+   rH   s    r&   r   zGTestCapturedErrorHandling.test_old_style_no_deprecation.<locals>.ol_bar/  s    $$%899r(   Trecordr'  c                      |        y r"   r#   r)  s    r&   rz   zDTestCapturedErrorHandling.test_old_style_no_deprecation.<locals>.foo5  rY  r(   r    There should not be any warningsmsg)r*  r,  r   rZ  r   r+  r*   r+   r   assertEqualr   r]  s       @r&   test_old_style_no_deprecationz7TestCapturedErrorHandling.test_old_style_no_deprecation%  s    
 	h(F(FG	 
#	: 
	: $$D1U""6#5#56m$ % 7
 SZ!C  E 2166 21s$    B>0B2%B>2B;	7B>>Cc                    t        j                  dt        j                         d t	              d        }t        j
                  d      5 }| j                  t              5  t        d      fd       }d d d        | j                  t        |      dd	
       d d d        y # 1 sw Y   /xY w# 1 sw Y   y xY w)NrR  c                      y r"   r#   rH   s    r&   r   zBTestCapturedErrorHandling._test_new_style_no_warnings.<locals>.bar@  r   r(   c                     t        d      rU  rV  rH   s    r&   r   zETestCapturedErrorHandling._test_new_style_no_warnings.<locals>.ol_barC  rW  r(   Trd  r'  c                      |        y r"   r#   r)  s    r&   rz   zBTestCapturedErrorHandling._test_new_style_no_warnings.<locals>.fooI  rY  r(   r   rg  rh  )r*  r,  r   rZ  r   r+  r*   r.  r   rj  r   r]  s       @r&   _test_new_style_no_warningsz5TestCapturedErrorHandling._test_new_style_no_warnings<  s    h(F(FG	 
#	6 
	6 $$D1U"">2m$ % 3
 SZ!C  E 2122 21s$   B4&B(:%B4(B1	-B44B=r$  defaultN)r4   r5   r6   __doc__r1  rI  rP  r_  r   run_test_in_subprocesstest_old_style_deprecationrk  rp  test_new_style_no_warnings%test_default_new_style_no_deprecationr#   r(   r&   r  r    s    C:*I40"!@!@!@(+6"!"# %X$$(+6EE(E("!@!@!@(+6"!"#-,KH,K,K()4-!-#)r(   r  __main__)4rr  r<  r:  numpyr=   r   r*  r   r   r   r   
numba.corer   numba.experimentalr   numba.extendingr   r	   r
   r   numba.core.compilerr   numba.core.untyped_passesr   r   r   numba.core.typed_passesr   r   r   r   numba.core.compiler_machineryr   numba.core.types.functionsr   r   numba.tests.supportr   r   r   r   r   r   unittestr   r8   rC   r   r  r  r4   mainr#   r(   r&   <module>r     s       	  " "  (1 1 ,6 6F F 5 D> > ;h&7&7 ;&7x00 7q7H-- q7hrE)) rEj?h6G6G ?`#X `#F zHMMO r(   