o
    IAf4                     @   s\   	 d dl mZ d dlmZ dgZG dd dZedd ZG dd dZd d	lm	Z	m
Z
 d
S )    )ref)contextmanagerlocalc                   @   s*   e Zd Z	 dZdd Zdd Zdd ZdS )	
_localimpl)keydicts	localargs	locallock__weakref__c                 C   s   dt t|  | _i | _d S )Nz_threading_local._localimpl.)stridr   r   )self r   '/usr/lib/python3.10/_threading_local.py__init__   s   
z_localimpl.__init__c                 C   s   	 t  }| jt| d S )N   )current_threadr   r   )r   threadr   r   r   get_dict   s   z_localimpl.get_dictc                    sj   	 i }| j }t }t|}|ffdd	}|f fdd	}t| | t|| |j|< |f| j|< |S )Nc                    s     }|d ur|j |= d S d S N)__dict__)_r   r   )wrthreadr   r   local_deleted   s   z-_localimpl.create_dict.<locals>.local_deletedc                    s"     }|d ur|j |}d S d S r   )r   pop)r   idtr   dct)wrlocalr   r   thread_deleted   s   z._localimpl.create_dict.<locals>.thread_deleted)r   r   r   r   r   r   )r   Z	localdictr   r   r   r   r   r   )r   r   r   create_dict   s   


z_localimpl.create_dictN)__name__
__module____qualname__	__slots__r   r   r   r   r   r   r   r      s    r   c                 c   s    t | d}z| }W n ty'   | }|j\}}| j|i | Y nw |j t | d| d V  W d    d S 1 sAw   Y  d S )N_local__implr   )	object__getattribute__r   KeyErrorr   r   r   r	   __setattr__)r   implr   argskwr   r   r   _patch   s   
"r,   c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )r   )r$   r   c                O   sX   |s|r| j tj u rtdt| }t }||f|_t |_t|d| |	  |S )Nz*Initialization arguments are not supportedr$   )
r   r%   	TypeError__new__r   r   RLockr	   r(   r   )clsr*   r+   r   r)   r   r   r   r.      s   

zlocal.__new__c                 C   s8   t |  t| |W  d    S 1 sw   Y  d S r   )r,   r%   r&   r   namer   r   r   r&      s   

$zlocal.__getattribute__c                 C   sR   |dkrt d| jj t|  t| ||W  d    S 1 s"w   Y  d S Nr   z+%r object attribute '__dict__' is read-only)AttributeError	__class__r    r,   r%   r(   )r   r2   valuer   r   r   r(      s   
$zlocal.__setattr__c                 C   sP   |dkrt d| jj t|  t| |W  d    S 1 s!w   Y  d S r3   )r4   r5   r    r,   r%   __delattr__r1   r   r   r   r7      s   

$zlocal.__delattr__N)r    r!   r"   r#   r.   r&   r(   r7   r   r   r   r   r      s    )r   r/   N)weakrefr   
contextlibr   __all__r   r,   r   	threadingr   r/   r   r   r   r   <module>   s     ,
&