Files
952-11/env/python/dll/Python312/Lib/__pycache__/code.cpython-312.pyc
T

164 lines
13 KiB
Plaintext
Raw Normal View History

2024-08-19 17:05:14 +08:00
Ë
*åf+ãó>—dZddlZddlZddlmZmZgd¢ZGd„d«ZGd„de«Zdd „Z e
d
k(riddl Z e j«Z
e
jd d d
¬«e
j«Zej"sej$j&rdZndZe e«yy)z?Utilities needed to emulate Python's interactive interpreter.
éN)ÚCommandCompilerÚcompile_command)ÚInteractiveInterpreterÚInteractiveConsoleÚinteractrcó:—eZdZdZd d„Zd
d„Zd„Zd d„Zd„Zd„Z y) rz÷Base class for InteractiveConsole.
This class deals with parsing and interpreter state (the user's
namespace); it doesn't deal with input buffering or prompting or
input file naming (the filename is always passed in explicitly).
Ncó>—|€dddœ}||_t«|_y)aConstructor.
The optional 'locals' argument specifies the dictionary in
which code will be executed; it defaults to a newly created
dictionary with key "__name__" set to "__console__" and key
"__doc__" set to None.
NÚ __console__)Ú__name__Ú__doc__)ÚlocalsrÚcompile)Úselfr
s ú@c:\Users\RCi\AppData\Local\Programs\Python\Python312\Lib\code.pyÚ__init__zInteractiveInterpreter.__init__s$€ð ˆ>Ø"/¸DÑAˆF؈Œ Ü&Ó(ˆ� ócóª— |j|||«}|€y|j |«y#tttf$r|j |«YywxYw)aˆCompile and run some source in the interpreter.
Arguments are as for compile_command().
One of several things can happen:
1) The input is incorrect; compile_command() raised an
exception (SyntaxError or OverflowError). A syntax traceback
will be printed by calling the showsyntaxerror() method.
2) The input is incomplete, and more input is required;
compile_command() returned None. Nothing happens.
3) The input is complete; compile_command() returned a code
object. The code is executed by calling self.runcode() (which
also handles run-time exceptions, except for SystemExit).
The return value is True in case 2, False in the other cases (unless
an exception is raised). The return value can be used to
decide whether to use sys.ps1 or sys.ps2 to prompt the next
line.
FT)rÚ
OverflowErrorÚ SyntaxErrorÚ
ValueErrorÚshowsyntaxerrorÚruncode)rÚsourceÚfilenameÚsymbolÚcodes rÚ runsourcez InteractiveInterpreter.runsource&s]€ð0 Ø—<‘< ¨°&Ó9ˆDð ˆ<àð
� ‰ �TÔØøôœ{¬JÐ7ò à × Ñ  Ô *Ùð ús‚*ª%AÁAcór— t||j«y#t$r‚|j«YyxYw)aƒExecute a code object.
When an exception occurs, self.showtraceback() is called to
display a traceback. All exceptions are caught except
SystemExit, which is reraised.
A note about KeyboardInterrupt: this exception may occur
elsewhere in this code, and may not always be caught. The
caller should be prepared to deal with it.
N)Úexecr
Ú
SystemExitÚ
showtraceback)rrs rrzInteractiveInterpreter.runcodeMs3€ð !Ü ��t—{‘{Õ #øÜò Ø ð !Ø × Ñ Ö ús‚™6có—tj«\}}}|t_|t_|t_|t_|rC|t ur; |j\}\}}}} t
||||| f«}|xt_t_tjtjur7tj||«}
|jdj|
««ytj|||«y#t$rYŒzwxYw)apDisplay the syntax error that just occurred.
This doesn't display a stack trace because there isn't one.
If a filename is given, it is stuffed in the exception instead
of what was there before (because Python's parser always uses
"<string>" when reading from a string).
The output is written by self.write(), below.
ÚN)ÚsysÚexc_infoÚlast_excÚ last_typeÚ
last_valueÚlast_tracebackrÚargsrÚ
excepthookÚ__excepthook__Ú tracebackÚformat_exception_onlyÚwriteÚjoin) rrÚtypeÚvalueÚtbÚmsgÚdummy_filenameÚlinenoÚoffsetÚlineÚliness rrz&InteractiveInterpreter.showsyntaxerror`sÛ€ôŸ,™,›.‰ˆˆe�RØŒŒ ØŒŒ
ØŒŒØŒÔÙ ˜¤ Ñ+ð
6Ø>C¿j¹jÑ;�Ñ;�n f¨f°dô $ C¨(°F¸FÀDÐ)IÓJ�Ø05Ð5”” œsœ~Ü �>‰>œS×/Ñ/Ñ /Ü×3Ñ3°D¸%Ó@ˆEØ �J‰J�r—w‘w˜u“~Õ &ô
�N‰N˜4 ¨Õ +øôò
áð
úsÁC9Ã9 DÄDcó´—tj«x\t_t_}}|t_|dt_ t
j|d|d|j«}tjtjur!|jdj|««ntj|d|d|«dx}}y#dx}}wxYw)z®Display the exception that just occurred.
We remove the first stack item because it is our own code.
The output is written by self.write(), below.
érr#N)
r$r%r'r(r)r&r-Úformat_exceptionÚtb_nextr+r,r/r0)rÚlast_tbÚeir9s rr!z$InteractiveInterpreter.showtraceback„s¬€ô7:·l±l³nÐDÑ.ŒŒ
”s”~ w°Ø$ŒÔؘ!‘uŒŒ ð Ü×.Ñ.¨r°!©u°b¸±e¸W¿_¹_ÓMˆEÜ�~‰~¤×!3Ñ!3Ñ3Ø—
‘
˜2Ÿ7™7 5›>Õ*ô—‘˜r !™u b¨¡e¨WÔ5àÐ ˆG‘bø˜4Ð ˆG‘bús
ÁBCÃCcóB—tjj|«y)z•Write a string.
The base implementation writes to sys.stderr; a subclass may
replace this with a different implementation.
N)r$Ústderrr/)rÚdatas rr/zInteractiveInterpreter.writešs€ô �
‰
×јÕr)N)z<input>Úsingle)
r Ú
__module__Ú __qualname__r rrrrr!r/©rrrrs'„ñó )ó%òN!ó&",òH ó,rrcó4—eZdZdZdd„Zd„Zd d„Zd„Zd
d„Zy) rzÎClosely emulate the behavior of the interactive Python interpreter.
This class builds on InteractiveInterpreter and adds prompting
using the familiar sys.ps1 and sys.ps2, and input buffering.
Ncó^—tj||«||_|j«y)zÿConstructor.
The optional locals argument will be passed to the
InteractiveInterpreter base class.
The optional filename argument should specify the (file)name
of the input stream; it will show up in tracebacks.
N)rrrÚ resetbuffer)rr
rs rrzInteractiveConsole.__init__¬s'€ô ×'Ñ'¨¨fÔ5Ø ˆŒ
Ø ×ÑÕrcó—g|_y)zReset the input buffer.N)Úbuffer)rs rrIzInteractiveConsole.resetbufferºs €àˆ� rc óZ— tj tjd}|€O|j dtj
›dtj ›d|›d|jj›d � «n|r|j d
t|«z«d } |rtj}ntj} |j|«}|j|«} ŒI#t$rdt_YŒåwxYw#t$rdt_YŒîwxYw#t$r|j d«Yn6wxYw#t$r&|j d «|j«d }YŒƒwxYw|€)|j d
|jjz«y|dk7r|j d
|z«yy)aˆClosely emulate the interactive Python console.
The optional banner argument specifies the banner to print
before the first interaction; by default it prints a banner
similar to the one printed by the real Python interpreter,
followed by the current class name in parentheses (so as not
to confuse this with the real interpreter -- since it's so
close!).
The optional exitmsg argument specifies the exit message
printed when exiting. Pass the empty string to suppress
printing an exit message. If exitmsg is not given or None,
a default message is printed.
z>>> z... zFType "help", "copyright", "credits" or "license" for more information.NzPython z on ú
z
(z)
z%s
rz
KeyboardInterrupt
znow exiting %s...
r#)r$Úps1ÚAttributeErrorÚps2r/ÚversionÚplatformÚ __class__r ÚstrÚ raw_inputÚpushÚEOFErrorÚKeyboardInterruptrI)rÚbannerÚexitmsgÚcprtÚmoreÚpromptr8s rrzInteractiveConsole.interact¾ss€ð  Ü �GŠGð Ü �GŠGðXˆØ ˆ>Ø �JŠJÜŸ › ¤S§\£\²4ØŸ™×/Ó/ð1õ
2ñØ �J‰J�v¤ F£ Ñ+Ô ,؈Øð
ÙÜ ŸW™W‘Fä ŸW™W�Fð+ØŸ>™>¨&Ó1�Dð
 Ÿ9™9 T›?‘Dðøôò ØŒCŽGð ûôò ØŒCŽGð ûô$ òØ—J‘J˜tÔ$Ùðûô
%ò
Ø—
‘
Ð2Ô3Ø× Ñ Ô"Ø’ð
úð ˆ?Ø �J‰JÐ,¨t¯~©~×/FÑ/FÑFÕ GØ
˜Š]Ø �J‰J�v Ñ'Õ (ðsX‚C!“C;Â#D5Â=DÃD5Ã!C8Ã7C8Ã;DÄDÄD2Ä/D5Ä1D2Ä2D5Ä5,E$Å#E$cóΗ|jj|«dj|j«}|j||j«}|s|j «|S)aPush a line to the interpreter.
The line should not have a trailing newline; it may have
internal newlines. The line is appended to a buffer and the
interpreter's runsource() method is called with the
concatenated contents of the buffer as source. If this
indicates that the command was executed or invalid, the buffer
is reset; otherwise, the command is incomplete, and the buffer
is left as it was after the line was appended. The return
value is 1 if more input is required, 0 if the line was dealt
with in some way (this is the same as runsource()).