
    daf                        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  ej                         Z ej                         Z	 ej                         Z
d Zed        Ze j                  d        Z G d dej                        Zy)    N)import_fresh_modulec                     t        j                          t        j                  d      |       t        j                  |       fd       }|S )z;Decorator that ensures a function is only ever called once.Nc                  B    5           cd d d        S # 1 sw Y   y xY wN )cachedlocks   6/root/Python-3.12.4/Lib/test/test_zoneinfo/_support.pyinnerzcall_once.<locals>.inner   s      	8	 	 	s   )	threadingLock	functools	lru_cachewraps)fr   r   r	   s     @@r
   	call_oncer      sH    >>D&Y  &q)F__Q  L    c                  .    ddl } t        ddg      }|| fS )u  Retrieve two copies of zoneinfo: pure Python and C accelerated.

    Because this function manipulates the import system in a way that might
    be fragile or do unexpected things if it is run many times, it uses a
    `call_once` decorator to ensure that this is only ever called exactly
    one time — in other words, when using this function you will only ever
    get one copy of each module rather than a fresh import each time.
    r   Nzoneinfo	_zoneinfo)blocked)r   r   )c_module	py_modules     r
   get_modulesr      s       #JFIhr   c              #      K   t               }t        j                  j                  d|      }| t        j                  d<   d ||ur|t        j                  d<   yt        j                  j	                  d       yw)zMake sure sys.modules["zoneinfo"] refers to `module`.

    This is necessary because `pickle` will refuse to serialize
    an type calling itself `zoneinfo.ZoneInfo` unless `zoneinfo.ZoneInfo`
    refers to the same object.
    r   N)objectsysmodulesgetpop)moduleNOT_PRESENTold_zoneinfos      r
   set_zoneinfo_moduler$   +   sZ      (K;;??:{;L$CKK
	;&".J
#s   A:A<c                   R     e Zd Ze fd       Zej                  defd       Z xZ	S )ZoneInfoTestBasec                 X    | j                   j                  | _        t        |           y r   )r!   ZoneInfoklasssuper
setUpClass)cls	__class__s    r
   r+   zZoneInfoTestBase.setUpClass?   s    JJ''	r   Tc              #     K   d }|5  |r |       }d t         j                  d<   | j                  j                  }	 | j                  j	                  |       d  |rJt         j                  j                  d       j                         D ]  \  }}|t         j                  |<    | j                  j	                  |       	 d d d        y # |rJt         j                  j                  d       j                         D ]  \  }}|t         j                  |<    | j                  j	                  |       w xY w# 1 sw Y   y xY ww)Nc                      i } t        t        j                        D ]=  }|j                  dd      d   dk7  rt        j                  j	                  |      | |<   ? | S )N.   r   tzdata)listr   r   splitr    )tzdata_modulesmodnames     r
   pop_tzdata_modulesz;ZoneInfoTestBase.tzpath_context.<locals>.pop_tzdata_modulesF   s[    N, C==a(+x7*-++//'*Bw'	C "!r   r2   )r   r   r!   TZPATHreset_tzpathr    items)	selftzpathblock_tzdatar	   r7   r5   old_pathr6   r!   s	            r
   tzpath_contextzZoneInfoTestBase.tzpath_contextD   s    	"  	3 "4!5(,H%{{))H	3((0KKOOH-+9+?+?+A 6/5G,6 ((2)	3 	3  KKOOH-+9+?+?+A 6/5G,6 ((2)	3 	3s5   E3D8CA'D8	EA)D55D88E=E)
__name__
__module____qualname__classmethodr+   
contextlibcontextmanagerTZPATH_LOCKr?   __classcell__)r-   s   @r
   r&   r&   >   s4      26[ 3 3r   r&   )rD   r   r   r   unittesttest.support.import_helperr   r   OS_ENV_LOCKrF   TZPATH_TEST_LOCKr   r   rE   r$   TestCaser&   r   r   r
   <module>rM      s      
   :inninn!9>># 
    $ $$&3x(( &3r   