o w[e@svdZddlZddlZddejDZgdZdZdZdd Zd d Z d d Z dddZ GdddZ GdddZ 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__).0fnamerr/usr/lib/python3.10/codeop.py &sr)compile_commandCompileCommandCompilerii@cCs|dD]}|}|r|ddkrnq|dkrd}t[tdttfz||||WnBtysz||d||WYWddStyp}zdt|vrfWYd}~YWddSWYd}~nd}~wwYnwWdn1s~wY||||S)N r#evalpassignorezincomplete input) splitstripwarningscatch_warnings simplefilter SyntaxWarningDeprecationWarning SyntaxErrorstr)compilersourcefilenamesymbollineerrr_maybe_compile1s8      r cCs4t|}t|}d|vrd|vrdS||krdSdS)Nzwas never closedFT)repr)err1err2rep1rep2rrr_is_syntax_errorLsr&cCst|||ttBSN)compilePyCF_DONT_IMPLY_DEDENTPyCF_ALLOW_INCOMPLETE_INPUTrrrrrr_compileUsr,singlecCstt|||S)aCompile 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 "" 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). )r r,r+rrrr Xsr c@s eZdZdZddZddZdS)r zInstances 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*flagsselfrrr__init__rszCompile.__init__cCs<t||||jd}tD]}|j|j@r|j|jO_q |S)NT)r(r/ _featuresco_flags compiler_flag)r1rrrcodeobfeaturerrr__call__us  zCompile.__call__N__name__ __module__ __qualname____doc__r2r8rrrrr ms r c@s"eZdZdZddZd ddZdS) 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.cCs t|_dSr')r rr0rrrr2s zCommandCompiler.__init__r-r.cCst|j|||S)aCompile 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 "" 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). )r r)r1rrrrrrr8szCommandCompiler.__call__Nr-r.r9rrrrr |sr r>)r=rrall_feature_namesr3__all__r)r*r r&r,r r r rrrrs"