
    'g{                        S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
r
S SKr S SKrS SKJrJr  SSKJrJr  \	R(                  R+                  5       r\R/                  S5      =(       d    \R/                  S5      r\(       a	  SrSSKJr  OS	r\	R8                  S    S
:  r\(       a  S rOS r " S S\5      r  " S S\5      r!Su  q"q#S r$S r%S r& " S S\'5      r( " S S\(5      r)g! \ a    S SKr Nf = f)    N)STDIN_FILENOCHILD   )whichPtyProcessErrorsolarissunosF)	_fork_ptyT   c                     [        U /5      $ N)bytesis    7/usr/lib/python3/dist-packages/ptyprocess/ptyprocess.py_byter   (   s    aSz    c                     [        U 5      $ r   )chrr   s    r   r   r   +   s    1vr   c                       \ rS rSrSrg)FileNotFoundError.    N__name__
__module____qualname____firstlineno____static_attributes__r   r   r   r   r   .   s    dr   r   c                       \ rS rSrSrg)TimeoutError/   r   Nr   r   r   r   r!   r!   /   s    r   r!   )NNc                  \   [         b  [        b  g SSKJn Jn  SnS H>  n[        [        SU-  S5      nUb  [        US5      (       d  M-   UR                  5       nM@     Uc  [        S5      e[        [        R                  " U5      S   U   5      n[        [        R                  " U5      S   U    5      n[%        U5      q[%        U5      q g! [         a     M  f = f! [        [        [        [        [        R                  4 a#     SS	KJnJn  Xpe N^! [         a    S
u  pV  Nof = ff = f)z_Set constants _EOF and _INTR.

This avoids doing potentially costly operations on module load.
Nr   )VEOFVINTR)stdinstdoutz__%s__filenozNo stream has a fileno   )CEOFCINTR)r      )_EOF_INTRtermiosr$   r%   getattrsyshasattrr(   
ValueErrorord	tcgetattrImportErrorOSErrorIOErrorerrorr*   r+   r   )	r$   r%   fdnamestreamintreofr*   r+   s	            r   _make_eof_intrr?   3   s    	u0!'%DS(T/48F~WVX%>%>]]_ & :5667$$R(+E23'##B'*401 $KE:D'   ':w}}E 	!	!+ 3 	! KT3	!	!sN   9C CAC 
CC CC )D+	
DD'#D+&D''D+c                    Sn [         R                  " U 5      nU(       a  US   [         R                  -  US'   OUS   [         R                  ) -  US'    [         R                  " U [         R                  U5        g ! [         R                   aU  nUR                  S   [        R
                  :X  a.  [        UR                  S   UR                  S   < SU< S35      ee S nAff = f! [         aU  nUR                  S   [        R
                  :X  a.  [        UR                  S   UR                  S   < SU< S35      ee S nAff = f)Nz~setecho() may not be called on this platform (it may still be possible to enable/disable echo when spawning the child process)r   r   : .r   )
r/   r5   r9   argserrnoEINVALr8   ECHO	tcsetattrTCSANOW)r:   stateerrmsgattrerrs        r   _setechorM   ^   s    NF  $ q'GLL(Qq'W\\M)Q 	"goot4 == 88A;%,,&#((1+CHHQK'HII  88A;%,,&#((1+CHHQK'HIIs1   A= &C) =C&AC!!C&)
E3AEEc                     [        [        SS5      n[        R                  " SXSS5      n[        R
                  " XU5        g )N
TIOCSWINSZigtHHHHr   )r0   r/   structpackfcntlioctl)r:   rowscolsrO   ss        r   _setwinsizerX   v   s4    
 ,<JFD1-A	KK"r   c                      \ rS rSrSr\r\(       a5  \R                  R                  S5      r	SR                  S5      r\S 5       rO$\R                  r	Sr\R                  R                   rSrSrSrSrS r\  S#S j5       rS	 r\S
 5       r\S 5       rS rS rS$S jrS rS rS%S jr S r!S r"S&S jr#S r$S$S jr%S$S jrS r&S r'S r(S r)S'S jr*S r+S r,S r-S  r.S! r/S"r0g)(
PtyProcess   zuThis class represents a process running in a pseudoterminal.

The main constructor is the :meth:`spawn` classmethod.
asciiz
c                      [         R                  R                  R                  U 5      $ ! [         a2    [         R                  R                  U R                  SS5      5      s $ f = f)Nr\   replace)r1   r'   bufferwriteAttributeErrordecode)bs    r   write_to_stdoutPtyProcess.write_to_stdout   sT    Fzz((..q11! Fzz'')(DEEFs   (+ 9A'&A'Nc                 0   [        5         Xl        X l        [        R                  " USSS9n[        R                  " USSSS9n[        R
                  " X45      U l        SU l        SU l        S U l	        S U l
        S U l        SU l        SU l        SU l        g )Nrbr   )	bufferingwbF)rh   closefd皙?)r?   pidr:   ioopenBufferedRWPairfileobj
terminatedclosed
exitstatussignalstatusstatusflag_eofdelayafterclosedelayafterterminate)selfrl   r:   readfwritefs        r   __init__PtyProcess.__init__   s    DA.TQ>((7   # $' r   c                 
   [        U[        [        45      (       d  [        SU-  5      eUSS nUS   n[	        U5      n	U	c  [        SSU-  -   5      eU	nXS'   [        R                  " 5       u  p[        (       a  [        R                  " 5       u  pO[        R                  " 5       u  pU[        :X  GaN   [        [        /UQ76   U(       d   [+        [        S5        [        R0                  " U
5        [2        R2                  " U[2        R4                  [2        R6                  5        [9        S[:        R<                  " [:        R>                  5      S   5      n[A        [C        U5      U1-  5      n[E        S/U-   UU/-   5       H#  n[        RF                  " US   S	-   US	   5        M%     Ub  [        RH                  " U5        Ub   U" 5          Uc  [        R\                  " X5        O[        R^                  " XU5         U " X5      nUUl2        Ub  UUl3        Ub  UUl4        [        R0                  " U5        [        Rj                  " U
S5      n[        R0                  " U
5        [m        U5      S:w  an   URo                  SS5      u  nnn[q        [r        URu                  S5      [J        5      nU" URu                  SS5      5      nU[`        L a  [w        U5      Ul        Ue URx                  " U6   U$ ! [          a=  nUR"                  S   [$        R&                  [$        R(                  4;  a  e  SnAGNtSnAff = f! [         [,        R.                  4 a=  nUR"                  S   [$        R&                  [$        R(                  4;  a  e  SnAGNSnAff = f! [J         a  n[M        U5      RN                  nS
RQ                  U[S        U5      5      n[T        (       a  URW                  S5      n[        RX                  " UU5        [        R0                  " U5        [        RZ                  " S	5         SnAGNkSnAff = f! [`         a  nSRQ                  UR$                  [S        U5      5      n[T        (       a  URW                  S5      n[        RX                  " UU5        [        R0                  " U5        [        RZ                  " [        Rb                  5         SnAGNSnAff = f!   [K        SU-  5      e= f! [          aL  nUR"                  S   [$        R&                  [$        R(                  [$        Rz                  4;  a  e  SnAU$ SnAff = f)a  Start the given command in a child process in a pseudo terminal.

This does all the fork/exec type of stuff for a pty, and returns an
instance of PtyProcess.

If preexec_fn is supplied, it will be called with no arguments in the
child process before exec-ing the specified command.
It may, for instance, set signal handlers to SIG_DFL or SIG_IGN.

Dimensions of the psuedoterminal used for the subprocess can be
specified as a tuple (rows, cols), or the default (24, 80) will be used.

By default, all file descriptors except 0, 1 and 2 are closed. This
behavior can be overridden with pass_fds, a list of file descriptors to
keep open between the parent and the child.
z)Expected a list or tuple for argv, got %rNr   z%The command was not found or was not zexecutable: %s.Fi      r   z{}:0:{}utf-8zOSError:{}:{}i      :r\   r^   z)Subprocess failed, got bad error data: %r)>
isinstancelisttuple	TypeErrorr   r   ospipeuse_native_pty_forkptyforkr
   fork_ptyr   rX   r   r8   rC   rD   rE   ENOTTYrM   r/   r9   closerS   F_SETFD
FD_CLOEXECminresource	getrlimitRLIMIT_NOFILEsortedsetzip
closerangechdir	Exceptiontyper   formatstrPY3encoder`   _exitexecvexecvper7   EX_OSERRargvenv
launch_dirreadlensplitr0   builtinsrb   int
setwinsizeENXIO)clsr   cwdr   echo
preexec_fn
dimensionspass_fdscommandcommand_with_pathexec_err_pipe_readexec_err_pipe_writerl   r:   rL   max_fd	spass_fdspaireenametosendinstexec_err_dataerrclasserrno_srJ   exctype	exceptions                               r   spawnPtyProcess.spawn   sb   8 $u..G$NOO Awq'!'N$#$K$5$?%@ A A#Q 35'')/hhjGC  ((*GC %<L6:6 \51 HH'(KK+U]]E<L<LM ("4"4X5K5K"LQ"OPFs8}0C/DDEIQC)OY&-ABd1gaia1 C %
 L&;HHW+JJwc2 3| 	?DH?!DO 	$% 2D9
#$ }" ,9,?,?a,H)'6!(HOOG,DiP#FMM'9$EF	g%&)'lIO
  	OOZ(
 K  88A;u||U\\&BB C  / xx{5<<*FF G4 !   G,,E&--eSV<Fs!'w!7HH0&9HH01HHQKK   & )//		3s8D3#]]73F,f5,-%%&P5 K&3!4 5 5  	xx{5<<u{{"KK L 		s   6K8 M 	N Q +Q 9A+S- 'T  8
L?2L::L?N2NN
Q &BP;;Q 
S*BS%%S*-S= 
U
AUUc                    [        U 5      R                  nU R                  b  [        U R                  5      /nU R                  b  UR                  SU R                  -  5        U R                  b  UR                  SU R                  -  5        SR                  USR                  U5      5      $ SR                  XR                  U R                  5      $ )Nzenv=%rzcwd=%rz{}.spawn({})z, z{}(pid={}, fd={}))r   r   r   reprr   appendr   r   joinrl   r:   )ry   clsnamerC   s      r   __repr__PtyProcess.__repr__Z  s    t*%%99 O$Dxx#Htxx/0*Ht67!(($))D/BB '--gxxIIr   c                 R    [        U [        5      (       d  U R                  S5      $ U $ )Nr   )r   r   r   rW   s    r   _coerce_send_stringPtyProcess._coerce_send_stringh  s#    !U##88G$$r   c                     U $ r   r   r   s    r   _coerce_read_stringPtyProcess._coerce_read_stringn  s    r   c                 X    U R                   (       d   U R                  5         gg!    g= f)a,  This makes sure that no system resources are left open. Python only
garbage collects Python objects. OS file descriptors are not Python
objects, so they must be handled explicitly. If the child file
descriptor was opened outside of this class (passed to the constructor)
then this does not close it. N)rr   r   ry   s    r   __del__PtyProcess.__del__r  s(     {{

 s   % )c                     U R                   $ )zCThis returns the file descriptor of the pty for the child.
        )r:   r   s    r   r(   PtyProcess.fileno  s     wwr   c                 D   U R                   (       d  U R                  5         U R                  R                  5         [        R
                  " U R                  5        U R                  5       (       a!  U R                  U5      (       d  [        S5      eSU l
        SU l         gg)a  This closes the connection with the child application. Note that
calling close() more than once is valid. This emulates standard Python
behavior with files. Set force to True if you want to make sure that
the child is terminated (SIGKILL is sent if the child ignores SIGHUP
and SIGINT). zCould not terminate the child.TN)rr   flushrp   r   timesleeprw   isalive	terminater   r:   ry   forces     r   r   PtyProcess.close  so     {{JJLLL JJt++,||~~~~e,,)*JKKDGDK r   c                     g)zOThis does nothing. It is here to support the interface for a
File-like object. Nr   r   s    r   r   PtyProcess.flush  s     	r   c                 B    [         R                  " U R                  5      $ )a6  This returns True if the file descriptor is open and connected to a
tty(-like) device, else False.

On SVR4-style platforms implementing streams, such as SunOS and HP-UX,
the child pty may not appear as a terminal device.  This means
methods such as setecho(), setwinsize(), getwinsize() may raise an
IOError. )r   isattyr:   r   s    r   r   PtyProcess.isatty  s     yy!!r   c                     Ub  [         R                   " 5       U-   n U R                  5       (       d  gUS:  a  Ub  gUb  W[         R                   " 5       -
  n[         R                  " S5        MS  )ab  This waits until the terminal ECHO flag is set False. This returns
True if the echo mode is off. This returns False if the ECHO flag was
not set False before the timeout. This can be used to detect when the
child is waiting for a password. Usually a child application will turn
off echo mode when it is waiting for the user to enter a password. For
example, instead of expecting the "password:" prompt you can wait for
the child to set ECHO off::

    p = pexpect.spawn('ssh user@example.com')
    p.waitnoecho()
    p.sendline(mypassword)

If timeout==None then this method to block until ECHO flag is False.
Tr   Frk   )r   getechor   )ry   timeoutend_times      r   
waitnoechoPtyProcess.waitnoecho  s`      yy{W,H<<>>{w2""TYY[0JJsO r   c                     [         R                  " U R                  5      n[        US   [         R                  -  5      U l
        U R                  $ ! [         R                   aW  nSnUR                  S   [
        R                  :X  a.  [        UR                  S   UR                  S   < SU< S35      ee SnAff = f)a  This returns the terminal echo mode. This returns True if echo is
on or False if echo is off. Child applications that are expecting you
to enter a password often set ECHO False. See waitnoecho().

Not supported on platforms where ``isatty()`` returns False.  z,getecho() may not be called on this platformr   r   rA   rB   Nr   )r/   r5   r:   r9   rC   rD   rE   r8   boolrF   r   )ry   rK   rL   rJ   s       r   r   PtyProcess.getecho  s    	$$TWW-D a7<</0	yy }} 	CFxx{ell*chhqkV+LMM		s    A B=&AB88B=c                 <    [        U R                  U5        Xl        g)a  This sets the terminal echo mode on or off. Note that anything the
child sent before the echo will be lost, so you should be sure that
your input buffer is empty before you call setecho(). For example, the
following will work as expected::

    p = pexpect.spawn('cat') # Echo is on by default.
    p.sendline('1234') # We expect see this twice from the child...
    p.expect(['1234']) # ... once from the tty echo...
    p.expect(['1234']) # ... and again from cat itself.
    p.setecho(False) # Turn off tty echo
    p.sendline('abcd') # We will set this only once (echoed by cat).
    p.sendline('wxyz') # We will set this only once (echoed by cat)
    p.expect(['abcd'])
    p.expect(['wxyz'])

The following WILL NOT WORK because the lines sent before the setecho
will be lost::

    p = pexpect.spawn('cat')
    p.sendline('1234')
    p.setecho(False) # Turn off tty echo
    p.sendline('abcd') # We will set this only once (echoed by cat).
    p.sendline('wxyz') # We will set this only once (echoed by cat)
    p.expect(['1234'])
    p.expect(['1234'])
    p.expect(['abcd'])
    p.expect(['wxyz'])


Not supported on platforms where ``isatty()`` returns False.
N)rM   r:   r   )ry   rI   s     r   setechoPtyProcess.setecho  s    @ 	% 	r   c                     U R                   R                  U5      nUS:X  a  SU l        [        S5      eU$ ! [        [        4 a9  nUR                  S   [
        R                  :X  a  SU l        [        S5      ee SnAff = f)a  Read and return at most ``size`` bytes from the pty.

Can block if there is nothing to read. Raises :exc:`EOFError` if the
terminal was closed.

Unlike Pexpect's ``read_nonblocking`` method, this doesn't try to deal
with the vagaries of EOF on platforms that do strange things, like IRIX
or older Solaris systems. It handles the errno=EIO pattern used on
Linux, and the empty-string return used on BSD platforms and (seemingly)
on recent Solaris.
r   T,End Of File (EOF). Exception style platform.Nr   /End Of File (EOF). Empty string style platform.)	rp   read1r7   r8   rC   rD   EIOrv   EOFError)ry   sizerW   rL   s       r   r   PtyProcess.read  s}    	""4(A 8 DMLMM ! 	xx{eii' $MNN	s   7 B 4A;;B c                     U R                   R                  5       nUS:X  a  SU l        [        S5      eU$ ! [        [        4 a9  nUR                  S   [
        R                  :X  a  SU l        [        S5      ee SnAff = f)Read one line from the pseudoterminal, and return it as unicode.

Can block if there is nothing to read. Raises :exc:`EOFError` if the
terminal was closed.
r   Tr   Nr   r   )	rp   readliner7   r8   rC   rD   r   rv   r   )ry   rW   rL   s      r   r   PtyProcess.readline  s{    	%%'A 8 DMLMM ! 	xx{eii' $MNN	s   6 A?4A::A?c                 ~    U R                   R                  U5      nU(       a  U R                   R                  5         U$ r   )rp   r`   r   )ry   rc   r   ns       r   _writebPtyProcess._writeb-  s.    LLq!LL r   c                      U R                  XS9$ )zIWrite bytes to the pseudoterminal.

Returns the number of bytes written.
)r   )r  )ry   rW   r   s      r   r`   PtyProcess.write3  s    
 ||A|++r   c                     UR                  5       n[        U5      nSUs=::  a  S::  a2  O  O/U[        S5      -
  S-   n[        U5      nU R                  U5      U4$ SSSSSSSSS	S	S
SS.nX;  a  g[        XA   5      nU R                  U5      U4$ )zHelper method that wraps send() with mnemonic access for sending control
character to the child (such as Ctrl-C or Ctrl-D).  For example, to send
Ctrl-G (ASCII 7, bell, '')::

    child.sendcontrol('g')

See also, sendintr() and sendeof().
a   z   ar   r                     )@`[{\|]}^~_?)r   r   )lowerr4   r   r  )ry   charr	  byteds        r   sendcontrolPtyProcess.sendcontrol:  s     zz|I>c>CHq A8D<<%t++!"2"" =QW~||D!4''r   c                 8    U R                  [        5      [        4$ )a  This sends an EOF to the child. This sends a character which causes
the pending parent output buffer to be sent to the waiting child
program without waiting for end-of-line. If it is the first character
of the line, the read() in the user program returns 0, which signifies
end-of-file. This means to work as expected a sendeof() has to be
called at the beginning of a line. This method does not send a newline.
It is the responsibility of the caller to ensure the eof is sent at the
beginning of a line. )r  r-   r   s    r   sendeofPtyProcess.sendeofV  s     ||D!4''r   c                 8    U R                  [        5      [        4$ )zfThis sends a SIGINT to the child. It does not require
the SIGINT to be the first character on a line. )r  r.   r   s    r   sendintrPtyProcess.sendintrb  s     ||E"E))r   c                     U R                   $ )z@This returns True if the EOF exception was ever raised.
        )rv   r   s    r   r>   PtyProcess.eofh  s     }}r   c                 x   U R                  5       (       d  g U R                  [        R                  5        [        R
                  " U R                  5        U R                  5       (       d  gU R                  [        R                  5        [        R
                  " U R                  5        U R                  5       (       d  gU R                  [        R                  5        [        R
                  " U R                  5        U R                  5       (       d  gU(       aV  U R                  [        R                  5        [        R
                  " U R                  5        U R                  5       (       d  ggg! [         a:    [        R
                  " U R                  5        U R                  5       (       d   g gf = f)zThis forces a child process to terminate. It starts nicely with
SIGHUP and SIGINT. If "force" is True then moves onto SIGKILL. This
returns True if the child was terminated. This returns False if the
child could not be terminated. TF)r   killsignalSIGHUPr   r   rx   SIGCONTSIGINTSIGKILLr7   r   s     r   r   PtyProcess.terminaten  s    ||~~	IIfmm$JJt//0<<>>IIfnn%JJt//0<<>>IIfmm$JJt//0<<>>		&..)

4334||~~  		
 JJt//0<<>>		s'   AE5 -AE5 AE5 AE5 5?F98F9c                 ~   U R                  5       (       a$  [        R                  " U R                  S5      u  pOU R                  $ [        R
                  " U5      U l        [        R                  " U5      (       a;  X l        [        R
                  " U5      U l        SU l        SU l	        U R                  $ [        R                  " U5      (       a;  X l        SU l        [        R                  " U5      U l        SU l	        U R                  $ [        R                  " U5      (       a  [        S5      eU R                  $ )aM  This waits until the child exits. This is a blocking call. This will
not read any data from the child, so this will block forever if the
child has unread output and has terminated. In other words, the child
may have printed output then called exit(), but, the child is
technically still alive until its output is read by the parent. r   NTzCalled wait() on a stopped child process. This is not supported. Is some other process attempting job control with our child pid?)r   r   waitpidrl   rs   WEXITSTATUS	WIFEXITEDru   rt   rq   WIFSIGNALEDWTERMSIG
WIFSTOPPEDr   )ry   rl   ru   s      r   waitPtyProcess.wait  s     <<>>**TXXq1KC??"..0<< K nnV4DO $D"DO  ^^F## K"DO "F 3D"DO  ]]6""! #I J J r   c                    U R                   (       a  gU R                  (       a  SnO[        R                  n [        R                  " U R
                  U5      u  p#US:X  a+   [        R                  " U R
                  U5      u  p#US:X  a  gUS:X  a  g[        R                  " U5      (       a0  X0l        [        R                  " U5      U l        SU l        SU l         g[        R                  " U5      (       a0  X0l        SU l        [        R                   " U5      U l        SU l         g[        R"                  " U5      (       a  [        S5      eg! [         a/  nUR                  [        R                  :X  a  [        S5      ee SnAff = f! [         a/  nUR                  [        R                  :X  a  [        S5      ee SnAff = f)a:  This tests if the child process is running or not. This is
non-blocking. If the child was terminated then this will read the
exitstatus or signalstatus of the child. This returns True if the child
process appears to be running or False if not. It can take literally
SECONDS for Solaris to return the right status. Fr   zisalive() encountered condition where "terminated" is 0, but there was no child process. Did someone else call waitpid() on our process?Nzisalive() encountered condition that should never happen. There was no child process. Did someone else call waitpid() on our process?Tzisalive() encountered condition where child process is stopped. This is not supported. Is some other process attempting job control with our child pid?)rq   rv   r   WNOHANGr3  rl   r7   rD   ECHILDr   r5  ru   r4  rs   rt   r6  r7  r8  )ry   waitpid_optionsrl   ru   r   s        r   r   PtyProcess.isalive  s    ??==
  O jjO
	**TXX?KC !8 jj?C  ax!8<< K nnV4DO $D"DO  ^^F## K"DO "F 3D"DO  ]]6""! #6 7 7 m  	ww%,,&% '* + +
 	$  77ell*) +. / /
 s/   #E "#F 
F	*FF	
G*G  Gc                 r    U R                  5       (       a"  [        R                  " U R                  U5        gg)zSend the given signal to the child application.

In keeping with UNIX tradition it has a misleading name. It does not
necessarily kill the child unless you send the right signal. See the
:mod:`signal` module for constants representing signal numbers.
N)r   r   r+  rl   )ry   sigs     r   r+  PtyProcess.kill   s&     <<>>GGDHHc" r   c                     [        [        SS5      n[        R                  " SSSSS5      n[        R
                  " U R                  X5      n[        R                  " SU5      SS $ )zNReturn the window size of the pseudoterminal as a tuple (rows, cols).
        
TIOCGWINSZiht@rP   r   r   )r0   r/   rQ   rR   rS   rT   r:   unpack)ry   rD  rW   xs       r   
getwinsizePtyProcess.getwinsize  sT     WlJ?
KK1a+KK/}}VQ'!,,r   c                 .    [        U R                  X5      $ )a  Set the terminal window size of the child tty.

This will cause a SIGWINCH signal to be sent to the child. This does not
change the physical window size. It changes the size reported to
TTY-aware applications like vi or curses -- applications that respond to
the SIGWINCH signal.
)rX   r:   )ry   rU   rV   s      r   r   PtyProcess.setwinsize  s     477D//r   )rr   rw   rx   r   rs   r:   rp   rv   rl   rt   ru   rq   )NNTN)   P   r   )Tr   i   )F)1r   r   r   r   __doc__r   string_typer   r   linesepr   crlfstaticmethodrd   r1   r'   r`   encodingr   r   r   r|   classmethodr   r   r   r   r   r(   r   r   r   r   r   r   r   r   r  r   r#  r&  r>   r   r9  r   r+  rG  r   r   r   r   r   rZ   rZ      s<    K
**##G,}}W%		F 
	F ******HD
CJ', AE*,e eNJ  
  $
$	"6$"H6*,(8
(*&P:KZ
#-0r   rZ   c                   p   ^  \ rS rSrSr\(       a  \rO\rSU 4S jjr	S	U 4S jjr
U 4S jrU 4S jrSrU =r$ )
PtyProcessUnicodei  zUnicode wrapper around a process running in a pseudoterminal.

This class exposes a similar interface to :class:`PtyProcess`, but its read
methods return unicode, and its :meth:`write` accepts unicode.
c                    > [         [        U ]  X5        X0l        X@l        [
        R                  " U5      " US9U l        g )N)errors)superrV  r|   rS  codec_errorscodecsgetincrementaldecoderdecoder)ry   rl   r:   rS  rZ  	__class__s        r   r|   PtyProcessUnicode.__init__*  s5    /8 (33H=\Rr   c                 ^   > [         [        U ]  U5      nU R                  R	                  USS9$ )zRead at most ``size`` bytes from the pty, return them as unicode.

Can block if there is nothing to read. Raises :exc:`EOFError` if the
terminal was closed.

The size argument still refers to bytes, not unicode code points.
Ffinal)rY  rV  r   r]  rb   )ry   r   rc   r^  s      r   r   PtyProcessUnicode.read0  s1     #T/5||""1E"22r   c                 \   > [         [        U ]  5       nU R                  R	                  USS9$ )r   Fra  )rY  rV  r   r]  rb   )ry   rc   r^  s     r   r   PtyProcessUnicode.readline;  s/     #T35||""1E"22r   c                 `   > UR                  U R                  5      n[        [        U ]  U5      $ )z\Write the unicode string ``s`` to the pseudoterminal.

Returns the number of bytes written.
)r   rS  rY  rV  r`   )ry   rW   rc   r^  s      r   r`   PtyProcessUnicode.writeD  s*    
 HHT]]#&3A66r   )rZ  r]  rS  )r   strictrM  )r   r   r   r   rN  r   r   rO  unicoder|   r   r   r`   r   __classcell__)r^  s   @r   rV  rV    s1    
 S	337 7r   rV  )*r[  rD   rS   rm   r   r   r   r,  rQ   r1   r/   r   r   r6   __builtin__r   r   utilr   r   platformr  	_platform
startswith_is_solarisr    r
   version_infor   r   r7   r   r!   r-   r.   r?   rM   rX   objectrZ   rV  r   r   r   <module>rt     s      	 	 
    
  #
 & (LL 	 # "!  	qQ +G*%w%e&V0#\
0 \
0~+7
 +7_  #"#s   C6 6
DD