Your IP : 52.15.253.106
o
S�g��@svdZddlZddlZdd�ejD�Zgd�ZdZdZdd �Zd
d�Z dd
�Z
ddd�ZGdd�d�ZGdd�d�Z
dS)aAUtilities to compile possibly incomplete Python source code.
This module provides two interfaces, broadly similar to the builtin
function compile(), which take program text, a filename and a 'mode'
and:
- Return code object if the command is complete and valid
- Return None if the command is incomplete
- Raise SyntaxError, ValueError or OverflowError if the command is a
syntax error (OverflowError and ValueError can be produced by
malformed literals).
The two interfaces are:
compile_command(source, filename, symbol):
Compiles a single command in the manner described above.
CommandCompiler():
Instances of this class have __call__ methods identical in
signature to compile_command; the difference is that if the
instance compiles program text containing a __future__ statement,
the instance 'remembers' and compiles all subsequent program texts
with the statement in force.
The module also provides another class:
Compile():
Instances of this class act like the built-in function compile,
but with 'memory' in the sense described above.
�NcCsg|]}tt|��qS�)�getattr�
__future__)�.0Zfnamerr�-/opt/alt/python310/lib64/python3.10/codeop.py�
<listcomp>&s�r)�compile_command�Compile�CommandCompilerii@cCs|�d�D]}|��}|r|ddkrnq|dkrd}t���[t�dttf�z||||�WnBtysz||d||�WYWd�dStyp}zdt|�vrfWYd}~YWd�dSWYd}~nd}~wwYnwWd�n1s~wY||||�S)N�
r�#�eval�pass�ignorezincomplete input) �split�strip�warnings�catch_warnings�simplefilter�
SyntaxWarning�DeprecationWarning�SyntaxError�str)�compiler�source�filename�symbol�line�errr�_maybe_compile1s8�
�� �����
rcCs4t|�}t|�}d|vrd|vrdS||krdSdS)Nzwas never closedFT)�repr)Zerr1Zerr2Zrep1Zrep2rrr�_is_syntax_errorLsr!cCst|||ttB�S�N)�compile�PyCF_DONT_IMPLY_DEDENT�PyCF_ALLOW_INCOMPLETE_INPUT�rrrrrr�_compileUsr'�<input>�singlecCstt|||�S)a�Compile a command and determine whether it is incomplete.
Arguments:
source -- the source string; may contain \n characters
filename -- optional filename from which source was read; default
"<input>"
symbol -- optional grammar start symbol; "single" (default), "exec"
or "eval"
Return value / exceptions raised:
- Return a code object if the command is complete and valid
- Return None if the command is incomplete
- Raise SyntaxError, ValueError or OverflowError if the command is a
syntax error (OverflowError and ValueError can be produced by
malformed literals).
)rr'r&rrrrXsrc@s eZdZdZdd�Zdd�ZdS)r z�Instances of this class behave much like the built-in compile
function, but if one is used to compile text containing a future
statement, it "remembers" and compiles all subsequent program texts
with the statement in force.cCsttB|_dSr")r$r%�flags��selfrrr�__init__rszCompile.__init__cCs<t||||jd�}tD]}|j|j@r|j|jO_q|S)NT)r#r*� _features�co_flagsZ
compiler_flag)r,rrrZcodeobZfeaturerrr�__call__us�zCompile.__call__N��__name__�
__module__�__qualname__�__doc__r-r0rrrrr msr c@s"eZdZdZdd�Zd dd�ZdS)
r
a(Instances of this class have __call__ methods identical in
signature to compile_command; the difference is that if the
instance compiles program text containing a __future__ statement,
the instance 'remembers' and compiles all subsequent program texts
with the statement in force.cCst�|_dSr")r rr+rrrr-�szCommandCompiler.__init__r(r)cCst|j|||�S)a�Compile a command and determine whether it is incomplete.
Arguments:
source -- the source string; may contain \n characters
filename -- optional filename from which source was read;
default "<input>"
symbol -- optional grammar start symbol; "single" (default) or
"eval"
Return value / exceptions raised:
- Return a code object if the command is complete and valid
- Return None if the command is incomplete
- Raise SyntaxError, ValueError or OverflowError if the command is a
syntax error (OverflowError and ValueError can be produced by
malformed literals).
)rr)r,rrrrrrr0�szCommandCompiler.__call__N�r(r)r1rrrrr
|sr
r6)r5rrZall_feature_namesr.�__all__r$r%rr!r'rr r
rrrr�<module>s"�
?>