U
    g8                     @  s   d dl mZ d dl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	 d dl
Z
d dlZd dlZd dlmZ eG dd de	Zdddd	d
ZdddddZdS )    )annotationsN)InteractiveConsole)finalc                      s>   e Zd ZU ded< ddd fddZdd	d
ddZ  ZS )TrioInteractiveConsoledict[str, object]localsNzdict[str, object] | None)repl_localsc                   s&   t  j|d | jj jtjO  _d S )N)r   )super__init__compilecompilerflagsastZPyCF_ALLOW_TOP_LEVEL_AWAIT)selfr   	__class__ ./tmp/pip-unpacked-wheel-ks04xdmi/trio/_repl.pyr
      s    zTrioInteractiveConsole.__init__ztypes.CodeTypeNone)codereturnc                 C  s   t || j}t|r*tjtj	|}ntj
tj|}t|tjrt|jtrZ|jnFt|j|j t_t_|jjt_tjdkr|jt_ttjtjtj d S )N)      )typesFunctionTyper   inspectiscoroutinefunctiontrioZfrom_threadrunoutcomeZacapturerun_synccapture
isinstanceErrorerror
SystemExittypesys	last_type
last_value__traceback__last_tracebackversion_infolast_exc
excepthook)r   r   funcresultr   r   r   runcode   s    


zTrioInteractiveConsole.runcode)N)__name__
__module____qualname____annotations__r
   r1   __classcell__r   r   r   r   r      s   
r   r   )consoler   c                   sV   dt j dt j dtt dd d}ztj	| j
|I d H  W 5 tjddtd	 X d S )
Nz
trio REPL z on zv
Use "await" directly instead of "trio.run()".
Type "help", "copyright", "credits" or "license" for more information.
Zps1z>>> zimport trioignorez ^coroutine .* was never awaited$)messagecategory)r'   versionplatformgetattrwarningsfilterwarningsRuntimeWarningr   Z	to_threadr    Zinteract)r7   Zbannerr   r   r   run_repl:   s    "rA   r   )original_localsr   c              	   C  sT   t t dd l}W 5 Q R X dti}dD ]}| | ||< q*t|}tt| d S )Nr   r   >   __spec__r2   
__loader____file____builtins____package__)
contextlibsuppressImportErrorreadliner   r   r   rA   )rB   rK   r   keyr7   r   r   r   mainL   s    rM   )
__future__r   r   rH   r   r'   r   r>   r   r   r   r   Ztrio.lowlevelZ
trio._utilr   r   rA   rM   r   r   r   r   <module>   s   '