B
    u9a.                 @   sZ   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.7/_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                sh   i }| j }t }t|}|ffdd	}|f fdd	}t| | t|| |j|< |f| j|< |S )Nc                s     }|d k	r|j |= d S )N)__dict__)_r   r   )wrthreadr   r   local_deleted   s    z-_localimpl.create_dict.<locals>.local_deletedc                s     }|d k	r|j |}d S )N)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   sv   t | d}y| }W n2 tk
rJ   | }|j\}}| j|| Y nX |j t | d| d V  W d Q R X 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 k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   s    t |  t| |S Q R X d S )N)r+   r$   r%   )r   namer   r   r   r%      s    
zlocal.__getattribute__c          	   C   s:   |dkrt d| jj t|  t| ||S Q R X d S )Nr   z+%r object attribute '__dict__' is read-only)AttributeError	__class__r   r+   r$   r'   )r   r0   valuer   r   r   r'      s    
zlocal.__setattr__c          	   C   s8   |dkrt d| jj t|  t| |S Q R X d S )Nr   z+%r object attribute '__dict__' is read-only)r1   r2   r   r+   r$   __delattr__)r   r0   r   r   r   r4      s    
zlocal.__delattr__N)r   r    r!   r"   r-   r%   r'   r4   r   r   r   r   r      s
   )r   r.   N)weakrefr   
contextlibr   __all__r   r+   r   Z	threadingr   r.   r   r   r   r   <module>   s   ,&