
    wi                         d dl mZ d dlZd dlZd dlmZmZmZmZ d Z	ej
                            dd          d             Zd	 Zed
k    r  e	              e              e             dS dS )    )BytesION)Unpackerpackb	OutOfDataExtTypec                     t          t          g d                    } t          |           }|                                dk    sJ |                                dk    sJ |                                dk    sJ |                                dk    sJ |                                dk    sJ t          j        t                    5  |                                 d d d            d S # 1 swxY w Y   d S )N)            r   r	   r
   r   )r   r   r   read_array_headerunpackpytestraisesr   )funpackers     o/root/.openclaw/workspace/chatterbox_venv_py311/lib/python3.11/site-packages/srsly/tests/msgpack/test_unpack.py"test_unpack_array_header_from_filer      s3   lll##$$A{{H%%''1,,,,??!!!!??!!!!??!!!!??!!!!	y	!	!                   s   	C++C/2C/z'not hasattr(sys, 'getrefcount') == Truez-sys.getrefcount() is needed to pass this test)reasonc                     g fd} t          j        |           }t          | |           }t          j        |           |dz   k    sJ |                    t	          i g                     |                    t	          i g                     |                                i gk    sJ |                                i gk    sJ i i gi i ggk    sJ ~t          j        |           |k    sJ d S )Nc                 2                         |            | S )N)append)xresults    r   hookz'test_unpacker_hook_refcnt.<locals>.hook   s    a    )object_hook	list_hookr
   )sysgetrefcountr   feedr   r   )r   basecntupr   s      @r   test_unpacker_hook_refcntr$      s   
 F     od##G	dd	3	3	3B?4  GaK////GGE2$KKGGE2$KK99;;2$99;;2$b2$RD)))))
?4  G++++++r   c            	          G fddt                                  } |                     t          ddi                     |                                 ddik    sJ |                     t          dt	          dd          i                     |                                 ddik    sJ |                     t          dt	          dd          i                     |                                 dt	          dd          ik    sJ d S )	Nc                   (     e Zd Z fdZd Z xZS )*test_unpacker_ext_hook.<locals>.MyUnpackerc                 \    t          |                               | j        d           d S )NF)ext_hookraw)super__init___hook)self
MyUnpacker	__class__s    r   r,   z3test_unpacker_ext_hook.<locals>.MyUnpacker.__init__1   s.    *d##,,dje,LLLLLr   c                 L    |dk    rt          |          S t          ||          S )Nr	   )intr   )r.   codedatas      r   r-   z0test_unpacker_ext_hook.<locals>.MyUnpacker._hook4   s'    qyy4yy tT***r   )__name__
__module____qualname__r,   r-   __classcell__)r0   r/   s   @r   r/   r'   0   sS        	M 	M 	M 	M 	M 	M	+ 	+ 	+ 	+ 	+ 	+ 	+r   r/   ar	   s   123{   r
   s   321)r   r!   r   r   r   )r   r/   s    @r   test_unpacker_ext_hookr;   /   s    + + + + + + +X + + + z||HMM%a//"""??a((((MM%ga00122333??c
****MM%ga00122333??ga&8&8 9999999r   __main__)ior   r   r   srsly.msgpackr   r   r   r   r   markskipifr$   r;   r5    r   r   <module>rB      s          



  = = = = = = = = = = = =	 	 	 -:   , ,	 ,0: : :( z&&((( r   