asda?‰PNG  IHDR ? f ??C1 sRGB ??é gAMA ±? üa pHYs ? ??o¨d GIDATx^íüL”÷e÷Y?a?("Bh?_ò???¢§?q5k?*:t0A-o??¥]VkJ¢M??f?±8\k2íll£1]q?ù???T bisect.cpython-36.opt-2.pyc000064400000002546151027002730011407 0ustar003 \# @sVd ddZeZd ddZeZd ddZddd Zy dd lTWnek rPYnXdS)NcCsd|dkrtd|dkr t|}x2||krR||d}|||krH|}q"|d}q"W|j||dS)Nrzlo must be non-negative) ValueErrorleninsert)axlohimidr /usr/lib64/python3.6/bisect.py insort_rights     rcCsX|dkrtd|dkr t|}x2||krR||d}|||krH|}q"|d}q"W|S)Nrzlo must be non-negativerr)rr)rrr r r r r r bisect_rights     rcCsd|dkrtd|dkr t|}x2||krR||d}|||krL|d}q"|}q"W|j||dS)Nrzlo must be non-negativerr)rrr)rrr r r r r r insort_left/s    rcCsX|dkrtd|dkr t|}x2||krR||d}|||krL|d}q"|}q"W|S)Nrzlo must be non-negativerr)rr)rrr r r r r r bisect_leftCs    r)*)rN)rN)rN)rN)rZinsortrZbisectrrZ_bisect ImportErrorr r r r s     smtpd.cpython-36.opt-2.pyc000064400000057002151027002730011262 0ustar003 \@sZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z dddddgZejdZd ZGd d d Zead Zd ZdZd$ddZGdddejZGdddejZGdddeZGdddeZGdddeZGdddZddZ e!dkrVe Z"e"j#Z#de#krle#j$dZ%e&e#de%e'e(dgZ)e#e%ddZ#nddl*Z)e+e)e#Z,e,e"j-e"j.fe"j/e"j0fe"j1e"j2dZ3e"j4r2y ddl5Z5Wn.e6k re7dej8d ej9dYnXe5j:d!d"Z;yej4e;Wn.ek rTYnXdS)%N)warn) get_addr_specget_angle_addr SMTPChannel SMTPServerDebuggingServer PureProxy MailmanProxyzPython SMTP proxy version 0.3c@seZdZddZddZdS)DevnullcCsdS)N)selfmsgr r /usr/lib64/python3.6/smtpd.pywritefsz Devnull.writecCsdS)Nr )r r r rflushgsz Devnull.flushN)__name__ __module__ __qualname__rrr r r rr esr  z, icCs4ttttjd|r&t|tjdtj|dS)N)file)print__doc__globalssysstderrexit)coder r r rusagepsrc@seZdZdZdZdZejefddZe ddZ e dd d fd d Z d d Z ddZe ddZejddZe ddZejddZe ddZejddZe ddZejddZe ddZejddZe dd Zejd!d Ze d"d#Zejd$d#Ze d%d&Zejd'd&Ze d(d)Zejd*d)Ze d+d,Zejd-d,Ze d.d/Zejd0d/Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dS)SrricCs|S)Nr )xr r r|szSMTPChannel.c Cs*yt|jjStk r$|jSXdS)N)maxcommand_size_limitsvalues ValueErrorcommand_size_limit)r r r rmax_command_size_limit~sz"SMTPChannel.max_command_size_limitNFc Cstjj|||d||_||_||_||_||_||_|rF|rFt d|rdd|_ d|_ d|_ t |_nd|_ d|_ td|_ d |_|jd|_d |_|jjtj|_y|j|_Wn:tk r}z|j|jd tjkrdSd}~XnXtd t |jt!d |j"d|jt#fdS)N)mapzFdecode_data and enable_SMTPUTF8 cannot be set to True at the same timerz .s . FrzPeer:)rz 220 %s %s)$asynchat async_chat__init__ smtp_serverconnaddrdata_size_limitenable_SMTPUTF8 _decode_datar% _emptystring_linesep_dotsepNEWLINE_newlineord_set_rset_state seen_greeting extended_smtpr#clearsocketZgetfqdnfqdnZ getpeernamepeerOSErrorcloseargserrnoZENOTCONNrrepr DEBUGSTREAMpush __version__) r Zserverr1r2r3r(r4 decode_dataerrr r rr/s@   zSMTPChannel.__init__cCs.|j|_d|_g|_d|_d|_|jddS)NFrs )COMMAND smtp_statemailfromrcpttosrequire_SMTPUTF8 num_bytesset_terminator)r r r r_set_post_data_states z SMTPChannel._set_post_data_statecCs|jd|_g|_dS)Nr)rT received_datareceived_lines)r r r rr<szSMTPChannel._set_rset_statecCstdtd|jS)NzTAccess to __server attribute on SMTPChannel is deprecated, use 'smtp_server' instead)rDeprecationWarningr0)r r r r__serverszSMTPChannel.__servercCstdtd||_dS)NzRSetting __server attribute on SMTPChannel is deprecated, set 'smtp_server' insteadrW)rrXr0)r valuer r rrYscCstdtd|jS)NzUAccess to __line attribute on SMTPChannel is deprecated, use 'received_lines' insteadrW)rrXrV)r r r r__lineszSMTPChannel.__linecCstdtd||_dS)NzSSetting __line attribute on SMTPChannel is deprecated, set 'received_lines' insteadrW)rrXrV)r rZr r rr[scCstdtd|jS)NzRAccess to __state attribute on SMTPChannel is deprecated, use 'smtp_state' insteadrW)rrXrN)r r r r__stateszSMTPChannel.__statecCstdtd||_dS)NzPSetting __state attribute on SMTPChannel is deprecated, set 'smtp_state' insteadrW)rrXrN)r rZr r rr\scCstdtd|jS)NzXAccess to __greeting attribute on SMTPChannel is deprecated, use 'seen_greeting' insteadrW)rrXr=)r r r r __greetingszSMTPChannel.__greetingcCstdtd||_dS)NzVSetting __greeting attribute on SMTPChannel is deprecated, set 'seen_greeting' insteadrW)rrXr=)r rZr r rr]scCstdtd|jS)NzSAccess to __mailfrom attribute on SMTPChannel is deprecated, use 'mailfrom' insteadrW)rrXrO)r r r r __mailfromszSMTPChannel.__mailfromcCstdtd||_dS)NzQSetting __mailfrom attribute on SMTPChannel is deprecated, set 'mailfrom' insteadrW)rrXrO)r rZr r rr^scCstdtd|jS)NzQAccess to __rcpttos attribute on SMTPChannel is deprecated, use 'rcpttos' insteadrW)rrXrP)r r r r __rcpttosszSMTPChannel.__rcpttoscCstdtd||_dS)NzOSetting __rcpttos attribute on SMTPChannel is deprecated, set 'rcpttos' insteadrW)rrXrP)r rZr r rr_scCstdtd|jS)NzTAccess to __data attribute on SMTPChannel is deprecated, use 'received_data' insteadrW)rrXrU)r r r r__dataszSMTPChannel.__datacCstdtd||_dS)NzRSetting __data attribute on SMTPChannel is deprecated, set 'received_data' insteadrW)rrXrU)r rZr r rr`scCstdtd|jS)NzKAccess to __fqdn attribute on SMTPChannel is deprecated, use 'fqdn' insteadrW)rrXrA)r r r r__fqdn szSMTPChannel.__fqdncCstdtd||_dS)NzISetting __fqdn attribute on SMTPChannel is deprecated, set 'fqdn' insteadrW)rrXrA)r rZr r rrascCstdtd|jS)NzKAccess to __peer attribute on SMTPChannel is deprecated, use 'peer' insteadrW)rrXrB)r r r r__peerszSMTPChannel.__peercCstdtd||_dS)NzISetting __peer attribute on SMTPChannel is deprecated, set 'peer' insteadrW)rrXrB)r rZr r rrbscCstdtd|jS)NzKAccess to __conn attribute on SMTPChannel is deprecated, use 'conn' insteadrW)rrXr1)r r r r__conn szSMTPChannel.__conncCstdtd||_dS)NzISetting __conn attribute on SMTPChannel is deprecated, set 'conn' insteadrW)rrXr1)r rZr r rrc%scCstdtd|jS)NzKAccess to __addr attribute on SMTPChannel is deprecated, use 'addr' insteadrW)rrXr2)r r r r__addr+szSMTPChannel.__addrcCstdtd||_dS)NzISetting __addr attribute on SMTPChannel is deprecated, set 'addr' insteadrW)rrXr2)r rZr r rrd0scCs&tjj|t|d|jrdnddS)Nz zutf-8ascii)r-r.rIbytesrQ)r r r r rrI7s zSMTPChannel.pushcCs|d}|j|jkr|j}n|j|jkr*|j}|r<|j|krr#r&getattrrgr3splitr7r8rir:rUrBrOrProrpr0process_messagerT) r lineZszicommandargZmax_szmethodrktextrEkwargsZstatusr r rfound_terminatorLsd        zSMTPChannel.found_terminatorcCsH|s|jddS|jr&|jddS|j||_|jd|jdS)Nz501 Syntax: HELO hostnamez503 Duplicate HELO/EHLOz250 %s)rIr=r<rA)r r{r r r smtp_HELOs  zSMTPChannel.smtp_HELOcCs|s|jddS|jr&|jddS|j||_d|_|jd|j|jrr|jd|j|jdd7<|js|jd|jr|jd |jdd 7<|jd dS) Nz501 Syntax: EHLO hostnamez503 Duplicate HELO/EHLOTz250-%sz 250-SIZE %sMAILz 250-8BITMIMEz 250-SMTPUTF8 z250 HELP) rIr=r<r>rAr3r#r5r4)r r{r r r smtp_EHLOs&    zSMTPChannel.smtp_EHLOcCs|r|jdn |jddS)Nz501 Syntax: NOOPz250 OK)rI)r r{r r r smtp_NOOPs zSMTPChannel.smtp_NOOPcCs|jd|jdS)Nz221 Bye)rIZclose_when_done)r r{r r r smtp_QUITs zSMTPChannel.smtp_QUITcCs0t|}|d|j|kr,||djSdS)Nr)rhrsrt)r keywordr{Zkeylenr r r_strip_command_keywordsz"SMTPChannel._strip_command_keywordcCsF|sdS|jjdr$t|\}}n t|\}}|s<||fS|j|fS)Nr<)rr)lstrip startswithrrZ addr_spec)r r{addressrestr r r_getaddrs zSMTPChannel._getaddrcCsNi}xD|D]<}|jd\}}}|j s2|r6| r6dS|r>|nd||<q W|S)N=T) partitionisalnum)r paramsresultZparameqrZr r r _getparamss zSMTPChannel._getparamscCs|rd}|j}|dkr$|jdq|dkr8|jdq|dkr^d}|jrR||7}|j|q|dkrd }|jrx||7}|j|q|d kr|jd q|d kr|jd q|dkr|jdq|dkr|jdq|dkr|jdq|jdn |jddS)Nz [SP ]ZEHLOz250 Syntax: EHLO hostnameZHELOz250 Syntax: HELO hostnamerz 250 Syntax: MAIL FROM:
ZRCPTz250 Syntax: RCPT TO:
rgz250 Syntax: DATAZRSETz250 Syntax: RSETZNOOPz250 Syntax: NOOPZQUITz250 Syntax: QUITZVRFYz250 Syntax: VRFY
zD501 Supported commands: EHLO HELO MAIL RCPT DATA RSET NOOP QUIT VRFYzD250 Supported commands: EHLO HELO MAIL RCPT DATA RSET NOOP QUIT VRFY)rsrIr>)r r{ZextendedZlc_argr r r r smtp_HELPs:          zSMTPChannel.smtp_HELPcCs@|r2|j|\}}|r"|jdq<|jd|n |jddS)NzB252 Cannot VRFY user, but will accept message and attempt deliveryz502 Could not VRFY %sz501 Syntax: VRFY
)rrI)r r{rrr r r smtp_VRFYs  zSMTPChannel.smtp_VRFYcCs|js|jddStd|tdd}|jr4|d7}|dkrJ|j|dS|jd|}|j|\}}|sv|j|dS|j r|r|j|dS|jr|jddS|jj |_ |j |j }|dkr|j|dS|j s|j dd }|dkr|jd dS|jr>|j d d }|dkr&d|_n|d k r>|jddS|j dd}|r|jsh|j|dS|jrt||jkr|jddSt|jdkr|jddS||_td|jtd|jddS)Nz503 Error: send HELO firstz ===> MAIL)rz 501 Syntax: MAIL FROM:
z [SP ]zFROM:z503 Error: nested MAIL commandZBODY7BIT8BITMIMEz1501 Error: BODY can only be one of 7BIT, 8BITMIMEZSMTPUTF8FTz&501 Error: SMTPUTF8 takes no argumentsZSIZEz:552 Error: message size exceeds fixed maximum message sizerz:555 MAIL FROM parameters not recognized or not implementedzsender:z250 OK)rr)r=rIrrHr>rrrOrsrvrorr5popr4rQisdigitr3intrhkeys)r r{ syntaxerrrrZbodysmtputf8sizer r r smtp_MAILsh                     zSMTPChannel.smtp_MAILcCs|js|jddStd|td|js6|jddSd}|jrH|d7}|dkr^|j|dS|jd|}|j|\}}|s|j|dS|j r|r|j|dS|jj |_ |j |j }|dkr|j|dSt |j dkr|jd dS|jj|td |jtd|jd dS) Nz503 Error: send HELO firstz ===> RCPT)rz503 Error: need MAIL commandz501 Syntax: RCPT TO:
z [SP ]zTO:rz8555 RCPT TO parameters not recognized or not implementedzrecips:z250 OK)r=rIrrHrOr>rrrsrvrprrhrrPri)r r{rrrr r r smtp_RCPT7s@           zSMTPChannel.smtp_RCPTcCs(|r|jddS|j|jddS)Nz501 Syntax: RSETz250 OK)rIr<)r r{r r r smtp_RSETZs  zSMTPChannel.smtp_RSETcCsZ|js|jddS|js(|jddS|r:|jddS|j|_|jd|jddS)Nz503 Error: send HELO firstz503 Error: need RCPT commandz501 Syntax: DATAs . z#354 End data with .)r=rIrPrgrNrS)r r{r r r smtp_DATAas    zSMTPChannel.smtp_DATAcCs|jddS)Nz502 EXPN not implemented)rI)r r{r r r smtp_EXPNpszSMTPChannel.smtp_EXPN),rrrrMrgr& collections defaultdictr#propertyr'DATA_SIZE_DEFAULTr/rTr<Z_SMTPChannel__serversetterZ_SMTPChannel__lineZ_SMTPChannel__stateZ_SMTPChannel__greetingZ_SMTPChannel__mailfromZ_SMTPChannel__rcpttosZ_SMTPChannel__dataZ_SMTPChannel__fqdnZ_SMTPChannel__peerZ_SMTPChannel__connZ_SMTPChannel__addrrIrmrrrrrrrrrrrrrrrr r r rrws` &            >   # 6#c@s2eZdZeZedddfddZddZddZdS) rNFc Cs||_||_||_||_||_|r.|r.tdtjj||dyNt j |dt j i}|j |dd|dd|j |j||jdWn|jYn(Xtd|jjtjtj||ftddS) NzFdecode_data and enable_SMTPUTF8 cannot be set to True at the same time)r(typerrz0%s started at %s Local addr: %s Remote addr:%s)r)Z _localaddr _remoteaddrr3r4r5r%asyncore dispatcherr/r@Z getaddrinfoZ SOCK_STREAMZ create_socketZset_reuse_addrZbindZlistenrDr __class__rtimectimerH)r Z localaddrZ remoteaddrr3r(r4rKZ gai_resultsr r rr/xs*  zSMTPServer.__init__cCs6tdt|td|j||||j|j|j|j}dS)NzIncoming connection from %s)r)rrGrH channel_classr3Z_mapr4r5)r r1r2Zchannelr r rhandle_acceptedszSMTPServer.handle_acceptedcKstdS)N)NotImplementedError)r rBrOrPrkr~r r rrwszSMTPServer.process_message) rrrrrrr/rrwr r r rrts  c@seZdZddZddZdS)rcCsrd}|j}x`|D]X}|rP| rPd|d}t|tsDt|jd}t|d}t|tsbt|}t|qWdS)NrzX-Peer: rzutf-8) splitlines isinstancerjrGencoder)r rBrkZ inheaderslinesrxZ peerheaderr r r_print_message_contents     z&DebuggingServer._print_message_contentcKsXtd|r@|jdr&td|d|jdr@td|d|j||tddS)Nz%---------- MESSAGE FOLLOWS ----------rozmail options: %srpzrcpt options: %s z%------------ END MESSAGE ------------)rgetr)r rBrOrPrkr~r r rrws   zDebuggingServer.process_messageN)rrrrrwr r r rrscs,eZdZfddZddZddZZS)rcs.d|kr|drtdtt|j||dS)Nr4z$PureProxy does not support SMTPUTF8.)r%superrr/)r rEr~)rr rr/szPureProxy.__init__c Csh|jd}d}x|D]}|sP|d7}qW|j|d|dtj|}|j|||}td|tddS)Nrrrz X-Peer: %szwe got some refusals:)r)rvinsertr9rq_deliverrrH) r rBrOrPrkrryrxrefusedr r rrws    zPureProxy.process_messagec Csddl}i}yB|j}|j|jd|jdz|j|||}Wd|jXWn|jk r}ztdtd|j }WYdd}~Xnjt |j fk r}zHtd|j tdt |dd }t |dd} x|D]} || f|| <qWWYdd}~XnX|S) Nrrzgot SMTPRecipientsRefused)rZgotZ smtp_codeZ smtp_errorignore)smtplibZSMTPZconnectrZsendmailquitZSMTPRecipientsRefusedrrHZ recipientsrCZ SMTPExceptionrru) r rOrPrkrrseZerrcodeerrmsgrr r rrs$    "zPureProxy._deliver)rrrr/rwr __classcell__r r )rrrs cs$eZdZfddZddZZS)r cs.d|kr|drtdtt|j||dS)Nr4z'MailmanProxy does not support SMTPUTF8.)r%rrr/)r rEr~)rr rr/ szMailmanProxy.__init__cCs:ddlm}ddlm}ddlm}ddlm}g} x~|D]v} | jjdd} | jd} t| dkrhq:| d} t| dkr| d }nd }|j |  s:|d!krq:| j | | |fq:Wx| D]\} } }|j | qWt ddj |td|r|j|||}t d|tdi}||}|j|}|jds2||d<|jdsPtjtj|d<x| D]\} } }t d| td|j| }|s|j| dd}||| <|d kr|j|d dn|d kr|j|d dnh|d kr|j|d dnN|d kr|j|d dn4|d"krV|dkrd|d<nd |d<|j|d dqVWdS)#Nr)StringIO)Utils)Message)MailList@-rWrradminownerrequestrqleavezforwarding recips:rn)rzwe got refusals:fromZFromZdateZDatezsending message to)lock)tolist)Ztoadmin)Ztoowner)Z torequestZ subscribeZSubjectZ unsubscribe)rrrrrqr)rqr)iorZMailmanrrrlowerrvrhZ list_existsriremoverrqrHrrrrZEnqueue)r rBrOrPrkrrrrZ listnamesZrcptZlocalpartsZlistnamerzrZmlistsrr Zmlistr r rrwsd                    zMailmanProxy.process_message)rrrr/rwrr r )rrr s c@seZdZdZdZdZdZdS)OptionsTrNF)rrrsetuid classname size_limitr4r r r rr_src !Csty.tjtjdddddddddd g\}}Wn.tjk r\}ztd|WYdd}~XnXt}x|D]\}}|d'krtd qj|d(krtttjd qj|d)krd|_ qj|d*kr||_ qj|d+krtj a qj|d,krd|_ qj|d-krjyt|}||_Wqjtd|tj dtjdYqjXqjWt|dkr@d}d}nPt|dkr\|d }d}n4t|d kr||d }|d}ntdd!tj||jd"} | d krtdd#||d| |_yt|| dd|_Wn$tk rtdd$|YnX|jd"} | d kr"tdd%||d| |_yt|| dd|_Wn$tk rntdd&|YnX|S).Nrz nVhc:s:duzclass=Znosetuidversionhelpzsize=debugr-h--helpr-V --version-n --nosetuidF-c--class-d--debug-u --smtputf8T-s--sizezInvalid size: )rzlocalhost:8025z localhost:25rWzInvalid arguments: %s:zBad local spec: %szBad local port: %szBad remote spec: %szBad remote port: %s)rr)rr)rr)rr)rr)rr)rr)getoptrargverrorrrrrJrrrrrHr4rrrh COMMASPACErqrr localhost localportr% remotehost remoteport) ZoptsrEroptionsoptr{Zint_sizeZ localspecZ remotespecryr r r parseargsfsp         r__main__r)r)r4z7Cannot import module "pwd"; try running with -n option.)rnobodyrWz3Cannot setuid "nobody"; try running with -n option.)r)?rosrFrrr@rr-rwarningsrZemail._header_value_parserrr__all__rZprogramrJr rHr9rrrr.rrrrrr rrrrrrfindZlastdot __import__rlocalsmodrruZclass_rrrrrr4proxyrpwd ImportErrorrrrgetpwnamrPermissionErrorZloopKeyboardInterruptr r r rPsv   M-SB        ssl.cpython-36.pyc000064400000107120151027002730007771 0ustar003 Owhݭ@spdZddlZddlZddlZddlZddlZddlmZddlm Z m Z m ZddlZddlmZmZmZddlmZmZmZddlmZmZmZmZmZmZddlmZmZdd lm Z m!Z!m"Z"m#Z#ydd lm$Z$Wne%k rYnXdd lm&Z&m'Z'm(Z(m)Z)m*Z*dd lm+Z+dd lm,Z,e j-de.ddedej-de.ddede j-de.ddede j-de.ddedej-de.ddede j-de.ddede/j0Z1e/_1dde/j2j3DZ4e5e/ddZ6ej7dkrdd lm8Z8m9Z9dd!l:m:Z:m;Z;mZ>m?Z?ddl@Z@ddlAZAddlBZBeCZDejEr>d#gZFngZFe+ZGGd$d%d%eHZIdRd'd(ZJd)d*ZKd+d,ZLed-d.ZMd/d0ZNGd1d2d2ed2d3ZOGd4d5d5eOe ZPGd6d7d7eZQePjRfdddd8d9d:ZSe0feTd;ePjRdddddd<d=d>ZUeSZVeUZWGd?d@d@ZXGdAdBdBe:ZYddd;eTe0ddCdCdf dDdEZZdFdGZ[dHZ\dIZ]dJdKZ^dLdMZ_e0dfdNdOZ`dPdQZadS)Sa This module provides some more Pythonic support for SSL. Object types: SSLSocket -- subtype of socket.socket which does SSL over the socket Exceptions: SSLError -- exception raised for I/O errors Functions: cert_time_to_seconds -- convert time string used for certificate notBefore and notAfter functions to integer seconds past the Epoch (the time values returned from time.time()) fetch_server_certificate (HOST, PORT) -- fetch the certificate provided by the server running on HOST at port PORT. No validation of the certificate is performed. Integer constants: SSL_ERROR_ZERO_RETURN SSL_ERROR_WANT_READ SSL_ERROR_WANT_WRITE SSL_ERROR_WANT_X509_LOOKUP SSL_ERROR_SYSCALL SSL_ERROR_SSL SSL_ERROR_WANT_CONNECT SSL_ERROR_EOF SSL_ERROR_INVALID_ERROR_CODE The following group define certificate requirements that one side is allowing/requiring from the other side: CERT_NONE - no certificates from the other side are required (or will be looked at if provided) CERT_OPTIONAL - certificates are not required, but if provided will be validated, and if validation fails, the connection will also fail CERT_REQUIRED - certificates are required, and will be validated, and if validation fails, the connection will also fail The following constants identify various SSL protocol variants: PROTOCOL_SSLv2 PROTOCOL_SSLv3 PROTOCOL_SSLv23 PROTOCOL_TLS PROTOCOL_TLS_CLIENT PROTOCOL_TLS_SERVER PROTOCOL_TLSv1 PROTOCOL_TLSv1_1 PROTOCOL_TLSv1_2 The following constants identify various SSL alert message descriptions as per http://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-6 ALERT_DESCRIPTION_CLOSE_NOTIFY ALERT_DESCRIPTION_UNEXPECTED_MESSAGE ALERT_DESCRIPTION_BAD_RECORD_MAC ALERT_DESCRIPTION_RECORD_OVERFLOW ALERT_DESCRIPTION_DECOMPRESSION_FAILURE ALERT_DESCRIPTION_HANDSHAKE_FAILURE ALERT_DESCRIPTION_BAD_CERTIFICATE ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE ALERT_DESCRIPTION_CERTIFICATE_REVOKED ALERT_DESCRIPTION_CERTIFICATE_EXPIRED ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN ALERT_DESCRIPTION_ILLEGAL_PARAMETER ALERT_DESCRIPTION_UNKNOWN_CA ALERT_DESCRIPTION_ACCESS_DENIED ALERT_DESCRIPTION_DECODE_ERROR ALERT_DESCRIPTION_DECRYPT_ERROR ALERT_DESCRIPTION_PROTOCOL_VERSION ALERT_DESCRIPTION_INSUFFICIENT_SECURITY ALERT_DESCRIPTION_INTERNAL_ERROR ALERT_DESCRIPTION_USER_CANCELLED ALERT_DESCRIPTION_NO_RENEGOTIATION ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE ALERT_DESCRIPTION_UNRECOGNIZED_NAME ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY N) namedtuple)EnumIntEnumIntFlag)OPENSSL_VERSION_NUMBEROPENSSL_VERSION_INFOOPENSSL_VERSION) _SSLContext MemoryBIO SSLSession)SSLErrorSSLZeroReturnErrorSSLWantReadErrorSSLWantWriteErrorSSLSyscallError SSLEOFError)txt2objnid2obj) RAND_statusRAND_add RAND_bytesRAND_pseudo_bytes)RAND_egd)HAS_SNIHAS_ECDHHAS_NPNHAS_ALPN HAS_TLSv1_3)_DEFAULT_CIPHERS)_OPENSSL_API_VERSION _SSLMethodcCs|jdo|dkS)NZ PROTOCOL_PROTOCOL_SSLv23) startswith)namer$/usr/lib64/python3.6/ssl.py}sr&)sourceOptionscCs |jdS)NZOP_)r")r#r$r$r%r&sZAlertDescriptioncCs |jdS)NZALERT_DESCRIPTION_)r")r#r$r$r%r&sZSSLErrorNumbercCs |jdS)NZ SSL_ERROR_)r")r#r$r$r%r&s VerifyFlagscCs |jdS)NZVERIFY_)r")r#r$r$r%r&s VerifyModecCs |jdS)NZCERT_)r")r#r$r$r%r&scCsi|]\}}||qSr$r$).0r#valuer$r$r% sr-ZPROTOCOL_SSLv2win32)enum_certificates enum_crls)socketAF_INET SOCK_STREAMcreate_connection) SOL_SOCKETSO_TYPEz tls-uniquec@s eZdZdS)CertificateErrorN)__name__ __module__ __qualname__r$r$r$r%r7sr7c Csg}|s dS|jd^}}|jd}||kr|jdsx|jdr|jtj|n|jtj|j ddx|D]}|jtj|qWtj d d j |d tj }|j |S) zhMatching according to RFC 6125, section 6.4.3 http://tools.ietf.org/html/rfc6125#section-6.4.3 F.*z,too many wildcards in certificate DNS name: z[^.]+zxn--z\*z[^.]*z\Az\.z\Z)splitcountr7reprlowerappendr"reescapereplacecompilejoin IGNORECASEmatch) ZdnhostnameZ max_wildcardsZpatsZleftmostZ remainderZ wildcardsZfragZpatr$r$r%_dnsname_matchs&   rKcCstj|j}||kS)zExact matching of IP addresses. RFC 6125 explicitly doesn't define an algorithm for this (section 1.7.2 - "Out of Scope"). ) ipaddress ip_addressrstrip)Zipnamehost_ipZipr$r$r%_ipaddress_matchsrPcCsP|s tdytj|}Wntk r2d}YnXg}|jdf}xb|D]Z\}}|dkr||dkrpt||rpdS|j|qJ|dkrJ|dk rt||rdS|j|qJW|sxF|jdfD]6}x0|D](\}}|dkrt||rdS|j|qWqWt|dkr td |d j t t |fn,t|dkrDtd ||d fntd dS)a)Verify that *cert* (in decoded format as returned by SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125 rules are followed, but IP addresses are not accepted for *hostname*. CertificateError is raised on failure. On success, the function returns nothing. ztempty or no certificate, match_hostname needs a SSL socket or SSL context with either CERT_OPTIONAL or CERT_REQUIREDNZsubjectAltNameZDNSz IP AddressZsubjectZ commonNamer;z&hostname %r doesn't match either of %sz, zhostname %r doesn't match %rrz=no appropriate commonName or subjectAltName fields were found) ValueErrorrLrMgetrKrBrPlenr7rGmapr@)certrJrOZdnsnamesZsankeyr,subr$r$r%match_hostnames>    rXDefaultVerifyPathszQcafile capath openssl_cafile_env openssl_cafile openssl_capath_env openssl_capathcCsdtj}tjj|d|d}tjj|d|d}ttjj|rF|ndtjj|rX|ndf|S)z/Return paths to default cafile and capath. rr;N) _sslget_default_verify_pathsosenvironrRrYpathisfileisdir)partscafilecapathr$r$r%r]-s r]csDeZdZdZfZfddZefddZefddZZ S) _ASN1Objectz#ASN.1 object identifier lookup cstj|ft|ddS)NF)r#)super__new___txt2obj)clsoid) __class__r$r%rh@sz_ASN1Object.__new__cstj|ft|S)z3Create _ASN1Object from OpenSSL numeric ID )rgrh_nid2obj)rjZnid)rlr$r%fromnidCsz_ASN1Object.fromnidcstj|ft|ddS)z=Create _ASN1Object from short name, long name or OID T)r#)rgrhri)rjr#)rlr$r%fromnameIsz_ASN1Object.fromname) r8r9r:__doc__ __slots__rh classmethodrnro __classcell__r$r$)rlr%rf;s  rfznid shortname longname oidc@seZdZdZdZdZdS)PurposezDSSLContext purpose flags with X509v3 Extended Key Usage objects z1.3.6.1.5.5.7.3.1z1.3.6.1.5.5.7.3.2N)r8r9r:rp SERVER_AUTHZ CLIENT_AUTHr$r$r$r%rtPsrtcseZdZdZd"Zd#ZefddZefdd Zd$d dZ d%ddZ ddZ ddZ ddZ ejfddZefddZejfddZefddZejfddZefdd Zejfd!d ZZS)& SSLContextz|An SSLContext holds various SSL-related configuration options and data, such as certificates and possibly a private key.protocol __weakref__CAROOTcOstj||}|S)N)r rh)rjrwargskwargsselfr$r$r%rh^s zSSLContext.__new__cCs ||_dS)N)rw)r}rwr$r$r%__init__bszSSLContext.__init__FTNc Cst|||||||dS)N)sock server_sidedo_handshake_on_connectsuppress_ragged_eofsserver_hostname_context_session) SSLSocket)r}rrrrrsessionr$r$r% wrap_socketes zSSLContext.wrap_socketcCs|j||||d}t||dS)N)rr)r)Z _wrap_bio SSLObject)r}ZincomingZoutgoingrrrsslobjr$r$r%wrap_bioos zSSLContext.wrap_biocCsdt}xN|D]F}t|d}t|dks2t|dkr:td|jt||j|q W|j|dS)Nasciirz(NPN protocols must be 1 to 255 in length) bytearraybytesrSr rBextendZ_set_npn_protocols)r} npn_protocolsprotosrwbr$r$r%set_npn_protocolsus  zSSLContext.set_npn_protocolscCsdt}xN|D]F}t|d}t|dks2t|dkr:td|jt||j|q W|j|dS)Nrrrz)ALPN protocols must be 1 to 255 in length)rrrSr rBrZ_set_alpn_protocols)r}Zalpn_protocolsrrwrr$r$r%set_alpn_protocolss  zSSLContext.set_alpn_protocolsc Cszt}y@x:t|D].\}}}|dkr|dks6|j|kr|j|qWWntk rdtjdYnX|rv|j|d|S)NZx509_asnTz-unable to enumerate Windows certificate store)cadata)rr/rkrPermissionErrorwarningswarnload_verify_locations)r} storenamepurposeZcertsrUencodingZtrustr$r$r%_load_windows_store_certss z$SSLContext._load_windows_store_certscCsDt|tst|tjdkr8x|jD]}|j||q$W|jdS)Nr.) isinstancerf TypeErrorsysplatform_windows_cert_storesrZset_default_verify_paths)r}rrr$r$r%load_default_certss    zSSLContext.load_default_certscs ttjS)N)r(rgoptions)r})rlr$r%rszSSLContext.optionscstttjj||dS)N)rgrvr__set__)r}r,)rlr$r%rscs ttjS)N)r)rg verify_flags)r})rlr$r%rszSSLContext.verify_flagscstttjj||dS)N)rgrvrr)r}r,)rlr$r%rsc s*tj}yt|Stk r$|SXdS)N)rg verify_moder*rQ)r}r,)rlr$r%rs zSSLContext.verify_modecstttjj||dS)N)rgrvrr)r}r,)rlr$r%rs)rwrx)ryrz)FTTNN)FNN)r8r9r:rprqr PROTOCOL_TLSrhr~rrrrrrtrurpropertyrsetterrrrsr$r$)rlr%rvWs*      rv)rdrercCsdt|tst|tt}|tjkr0t|_d|_ |s<|s<|rL|j |||n|jt kr`|j ||S)zCreate a SSLContext object with default settings. NOTE: The protocol and settings may change anytime without prior deprecation. The values represent a fair balance between maximum compatibility and security. T) rrfrrvrrtru CERT_REQUIREDrcheck_hostnamer CERT_NONEr)rrdrercontextr$r$r%create_default_contexts     rF) cert_reqsrrcertfilekeyfilerdrerc Cst|tst|t|} |s$d| _|dk r2|| _|rZ$d?d@Z%dAdBZ&dCdDZ'dEdFZ(dadGdHZ)dIdJZ*dKdLZ+dMdNZ,dOdPZ-dbdRdSZ.dTdUZ/Z0S)crzThis class implements a subtype of socket.socket that wraps the underlying OS socket in an SSL context when necessary, and provides read and write methods over that channel.NFTrc6Cs:d|_|r||_n|r$| r$td|r6| r6td|rD| rD|}t||_||j_|rf|jj||rx|jj|||r|jj||r|jj|||_ ||_ ||_ ||_ ||_ ||_|jtttkrtd|r|rtd|dk rtd|jjr| rtd||_||_||_||_| |_|dk rftj||j|j|j|jd|j }|j!n,| dk rtj|| dntj|| | | d y |j"Wnt#k r}z|j$t$j%kr‚d }|j d k}|j&d y|j'd }Wn>t#k r(}z |j$t$j%t$j(fkrd }WYdd}~XnX|j&||rd}t)|j$|}||_*d|_+y |j,Wnt#k rxYnXz|Wdd}XWYdd}~XnXd}|j-|d |_.d|_||_/|r6yN|jj0|||}t1|||jd|_|r|j }|dkrtd|j2Wn$t#tfk r4|j,YnXdS)Nz5certfile must be specified for server-side operationszcertfile must be specifiedz!only stream sockets are supportedz4server_hostname can only be specified in client modez,session can only be specified in client modez'check_hostname requires server_hostname)familytypeprotofileno)r)rrrFrr;z5Closed before TLS handshake with data in recv buffer.T)rrgzHdo_handshake_on_connect should not be specified for non-blocking sockets)3rrrQrvrrrrZ set_ciphersrrr ssl_versionca_certsciphersZ getsockoptr5r6r3rrrrrrrr1r~rrrr gettimeoutdetach getpeernameOSErrorerrnoZENOTCONNZ setblockingrecvZEINVALr reasonZlibraryclose settimeoutZ_closed _connected _wrap_socketrr)r}rrrrrrrrrrrrrrrrrrZ sock_timeouteZ connectedZblockingZnotconn_pre_handshake_datarZ notconn_pre_handshake_data_errorrtimeoutr$r$r%r~s                      zSSLSocket.__init__cCs|jS)N)r)r}r$r$r%r0szSSLSocket.contextcCs||_||j_dS)N)rrr)r}rr$r$r%r4scCs|jdk r|jjSdS)z!The SSLSession for client socket.N)rr)r}r$r$r%r9s zSSLSocket.sessioncCs||_|jdk r||j_dS)N)rrr)r}rr$r$r%r?s cCs|jdk r|jjSdS)z.Was the client session reused during handshakeN)rr)r}r$r$r%rEs zSSLSocket.session_reusedcCstd|jjdS)NzCan't dup() %s instances)rrlr8)r}r$r$r%dupKsz SSLSocket.dupcCsdS)Nr$)r}msgr$r$r% _checkClosedOszSSLSocket._checkClosedcCs|js|jdS)N)rr)r}r$r$r%_check_connectedSszSSLSocket._check_connectedcCst|j|jstdy|jj||Stk rn}z.|jdtkr\|jr\|dk rVdSdSnWYdd}~XnXdS)zORead up to LEN bytes and return them. Return zero-length string on EOF.z'Read on closed or unwrapped SSL socket.rNr)rrrQrr r{Z SSL_ERROR_EOFr)r}rSrxr$r$r%r[szSSLSocket.readcCs"|j|jstd|jj|S)zhWrite DATA to the underlying SSL channel. Returns number of bytes of DATA actually transmitted.z(Write on closed or unwrapped SSL socket.)rrrQr)r}rr$r$r%rmszSSLSocket.writecCs|j|j|jj|S)zReturns a formatted version of the data in the certificate provided by the other end of the SSL channel. Return None if no certificate was provided, {} if a certificate was provided, but not validated.)rrrr)r}rr$r$r%rvszSSLSocket.getpeercertcCs*|j|j stj rdS|jjSdS)N)rrr\rr)r}r$r$r%rszSSLSocket.selected_npn_protocolcCs*|j|j stj rdS|jjSdS)N)rrr\rr)r}r$r$r%rsz SSLSocket.selected_alpn_protocolcCs |j|jsdS|jjSdS)N)rrr)r}r$r$r%rszSSLSocket.ciphercCs|j|jsdS|jjS)N)rrr)r}r$r$r%rszSSLSocket.shared_cipherscCs |j|jsdS|jjSdS)N)rrr)r}r$r$r%rszSSLSocket.compressioncCsB|j|jr0|dkr$td|j|jj|Stj|||SdS)Nrz3non-zero flags not allowed in calls to send() on %s)rrrQrlrr1send)r}rflagsr$r$r%rs  zSSLSocket.sendcCsH|j|jrtd|jn&|dkr4tj|||Stj||||SdS)Nz%sendto not allowed on instances of %s)rrrQrlr1sendto)r}rZ flags_or_addraddrr$r$r%rs zSSLSocket.sendtocOstd|jdS)Nz&sendmsg not allowed on instances of %s)rrl)r}r{r|r$r$r%sendmsgszSSLSocket.sendmsgcCs|j|jr|dkr$td|jd}t|L}|jd6}t|}x&||krl|j||d}||7}qHWWdQRXWdQRXntj |||SdS)Nrz6non-zero flags not allowed in calls to sendall() on %sB) rrrQrl memoryviewcastrSrr1sendall)r}rrr?ZviewZ byte_viewZamountrr$r$r%rs  "zSSLSocket.sendallcs,|jdkrtj|||S|j|||SdS)zSend a file, possibly by using os.sendfile() if this is a clear-text socket. Return the total number of bytes sent. N)rrgsendfileZ_sendfile_use_send)r}fileoffsetr?)rlr$r%rs zSSLSocket.sendfilecCs@|j|jr.|dkr$td|j|j|Stj|||SdS)Nrz3non-zero flags not allowed in calls to recv() on %s)rrrQrlrr1r)r}buflenrr$r$r%rs  zSSLSocket.recvcCsf|j|r|dkrt|}n |dkr*d}|jrR|dkrFtd|j|j||Stj||||SdS)Nirz8non-zero flags not allowed in calls to recv_into() on %s)rrSrrQrlrr1 recv_into)r}rnbytesrr$r$r%rs    zSSLSocket.recv_intocCs0|j|jrtd|jntj|||SdS)Nz'recvfrom not allowed on instances of %s)rrrQrlr1recvfrom)r}rrr$r$r%rs  zSSLSocket.recvfromcCs2|j|jrtd|jntj||||SdS)Nz,recvfrom_into not allowed on instances of %s)rrrQrlr1 recvfrom_into)r}rrrr$r$r%rs  zSSLSocket.recvfrom_intocOstd|jdS)Nz&recvmsg not allowed on instances of %s)rrl)r}r{r|r$r$r%recvmsgszSSLSocket.recvmsgcOstd|jdS)Nz+recvmsg_into not allowed on instances of %s)rrl)r}r{r|r$r$r% recvmsg_intoszSSLSocket.recvmsg_intocCs |j|jr|jjSdSdS)Nr)rrr)r}r$r$r%r s zSSLSocket.pendingcCs|jd|_tj||dS)N)rrr1r)r}Zhowr$r$r%rszSSLSocket.shutdowncCs.|jr|jj}d|_|Stdt|dS)NzNo SSL wrapper around )rrrQstr)r}sr$r$r%rs  zSSLSocket.unwrapcCs$|jr|jjStdt|dS)NzNo SSL wrapper around )rrrQr)r}r$r$r%rs z&SSLSocket.verify_client_post_handshakecCsd|_tj|dS)N)rr1 _real_close)r}r$r$r%r#szSSLSocket._real_closec CsF|j|j}z$|dkr(|r(|jd|jjWd|j|XdS)zPerform a TLS/SSL handshake.gN)rrrrr)r}blockrr$r$r%r's  zSSLSocket.do_handshakec Cs|jrtd|jrtd|jj|d|j}t|||jd|_y>|rTt j ||}nd}t j |||s|d|_|j r||j |Sttfk rd|_YnXdS)Nz!can't connect in server-side modez/attempt to connect already-connected SSLSocket!F)rrT)rrQrrrrrrrr1 connect_exconnectrrr)r}rrrZrcr$r$r% _real_connect2s(  zSSLSocket._real_connectcCs|j|ddS)zQConnects to remote ADDR, and then wraps the connection in an SSL channel.FN)r)r}rr$r$r%rKszSSLSocket.connectcCs |j|dS)zQConnects to remote ADDR, and then wraps the connection in an SSL channel.T)r)r}rr$r$r%rPszSSLSocket.connect_excCs.tj|\}}|jj||j|jdd}||fS)zAccepts a new connection from a remote client, and returns a tuple containing that new connection wrapped with a server-side SSL channel, and the address of the remote client.T)rrr)r1acceptrrrr)r}Znewsockrr$r$r%rUs zSSLSocket.accept tls-uniquecCs|jdkrdS|jj|S)zGet channel binding data for current connection. Raise ValueError if the requested `cb_type` is not supported. Return bytes of the data or None if the data is not available (e.g. before the handshake). N)rr)r}rr$r$r%ras zSSLSocket.get_channel_bindingcCs|jdkrdS|jjS)z Return a string identifying the protocol version used by the current SSL channel, or None if there is no established channel. N)rr)r}r$r$r%rjs zSSLSocket.version)N)rN)F)r)N)r)rN)rr)Nr)rr)Nr)F)r )1r8r9r:rprrr2r3r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrsr$r$)rlr%rs`|             rTc Cst|||||||||| d S)N) rrrrrrrrrr)r) rrrrrrrrrrr$r$r%rts rc Csddlm}ddlm}d}d}y|j|ddjd}Wn$tk rbtd||fYn0X||dd|}||d|f|ddSdS)aReturn the time in seconds since the Epoch, given the timestring representing the "notBefore" or "notAfter" date from a certificate in ``"%b %d %H:%M:%S %Y %Z"`` strptime format (C locale). "notBefore" or "notAfter" dates must use UTC (RFC 5280). Month is one of: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec UTC should be specified as GMT (see ASN1_TIME_print()) r)strptime)timegmJanFebMarAprMayJunJulAugSepOctNovDecz %d %H:%M:%S %Y GMTNr[r;z*time data %r does not match format "%%b%s"rZ) r r rrrrrrrrrr)Ztimer Zcalendarr indextitlerQ)Z cert_timer r ZmonthsZ time_formatZ month_numberZttr$r$r%cert_time_to_secondss  rz-----BEGIN CERTIFICATE-----z-----END CERTIFICATE-----cCs2ttj|dd}tdtj|ddtdS)z[Takes a certificate in binary DER format and returns the PEM version of it as a string.ASCIIstrict @)rbase64Zstandard_b64encode PEM_HEADERtextwrapZfill PEM_FOOTER)Zder_cert_bytesfr$r$r%DER_cert_to_PEM_certsr%cCs\|jtstdt|jjts0tdt|jtttt }tj|j ddS)zhTakes a certificate in ASCII PEM format and returns the DER-encoded version of it as a byte sequencez(Invalid PEM encoding; must start with %sz&Invalid PEM encoding; must end with %srr) r"r!rQstripendswithr#rSr Z decodebytesencode)Zpem_cert_stringdr$r$r%PEM_cert_to_DER_certs r*c Csd|\}}|dk rt}nt}t|||d}t|&}|j|}|jd} WdQRXWdQRXt| S)zRetrieve the certificate from the server at the specified address, and return it as a PEM-encoded string. If 'ca_certs' is specified, validate the server cert against it. If 'ssl_version' is specified, use it in the connection attempt.N)rrdT)rr_create_stdlib_contextr4rrr%) rrrhostZportrrrZsslsockZdercertr$r$r%get_server_certificates  r-cCs tj|dS)Nz )_PROTOCOL_NAMESrR)Z protocol_coder$r$r%get_protocol_namesr/)r;)brprLr"rCrr^ collectionsrenumrZ_EnumrZ_IntEnumrZ_IntFlagr\rrrr r r r r rrrrrrirrmrrrrr ImportErrorrrrrrrr_convertr8r rr! __members__itemsr.getattrZ_SSLv2_IF_EXISTSrr/r0r1r2r3r4r5r6r rrrZ socket_errorZHAS_TLS_UNIQUErZ_RESTRICTED_SERVER_CIPHERSrQr7rKrPrXrYr]rfrtrvrurrrZ_create_default_https_contextr+rrrrr!r#r%r*r-r/r$r$r$r%[s        1 4g(O   operator.cpython-36.pyc000064400000033133151027002730011025 0ustar003 \o*6@s(dZddddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6g6Zd7d8lmZd9d&Zd:d#Zd;d Zdd Z d?d-Z d@d5Z dAdZ dBdZdCdZdDdZdEdZdFd ZdGdZdHdZeZdId%ZdJd)ZdKd*ZdLd'ZdMd,ZdNd.ZdOd/ZdPd0ZdQd1ZdRd3ZdSd4ZdTd6Z dUdZ!dVdZ"dWdZ#dXdZ$dYd Z%dZdZ&d[d2Z'dqd\d$Z(Gd]ddZ)Gd^d d Z*Gd_d(d(Z+d`dZ,dadZ-dbdZ.dcdZ/dddZ0dedZ1dfdZ2dgdZ3dhdZ4didZ5djdZ6dkdZ7dld!Z8dmd"Z9y d7dnl:TWne;k rbYnXd7dol:mZeZeZ?e Z@e ZAe ZBeZCeZDeZEeZFeZGeZHeZIeZJeZKeZLeZMeZNeZOeZPeZQeZReZSeZTe ZUe!ZVe"ZWe$ZXe%ZYe'ZZe,Z[e-Z\e.Z]e/Z^e0Z_e1Z`e2Zae3Zbe4Zce5Zde6Zee7Zfe8Zge9ZhdpS)ras Operator Interface This module exports a set of functions corresponding to the intrinsic operators of Python. For example, operator.add(x, y) is equivalent to the expression x+y. The function names are those used for special methods; variants without leading and trailing '__' are also provided for convenience. This is the pure Python implementation of the module. absaddand_ attrgetterconcatcontainscountOfdelitemeqfloordivgegetitemgtiaddiandiconcat ifloordivilshiftimatmulimodimulindexindexOfinvinvertioripowirshiftis_is_notisub itemgetteritruedivixorle length_hintlshiftltmatmul methodcallermodmulnenegnot_or_pospowrshiftsetitemsubtruedivtruthxor)rcCs||kS)zSame as a < b.)abr8r8 /usr/lib64/python3.6/operator.pyr&scCs||kS)zSame as a <= b.r8)r9r:r8r8r;r#scCs||kS)zSame as a == b.r8)r9r:r8r8r;r #scCs||kS)zSame as a != b.r8)r9r:r8r8r;r+'scCs||kS)zSame as a >= b.r8)r9r:r8r8r;r +scCs||kS)zSame as a > b.r8)r9r:r8r8r;r /scCs| S)zSame as not a.r8)r9r8r8r;r-5scCs |rdSdS)z*Return True if a is true, False otherwise.TFr8)r9r8r8r;r59scCs||kS)zSame as a is b.r8)r9r:r8r8r;r=scCs||k S)zSame as a is not b.r8)r9r:r8r8r;rAscCst|S)zSame as abs(a).)_abs)r9r8r8r;rGscCs||S)zSame as a + b.r8)r9r:r8r8r;rKscCs||@S)zSame as a & b.r8)r9r:r8r8r;rOscCs||S)zSame as a // b.r8)r9r:r8r8r;r SscCs|jS)zSame as a.__index__().) __index__)r9r8r8r;rWscCs|S)z Same as ~a.r8)r9r8r8r;r[scCs||>S)zSame as a << b.r8)r9r:r8r8r;r%`scCs||S)zSame as a % b.r8)r9r:r8r8r;r)dscCs||S)zSame as a * b.r8)r9r:r8r8r;r*hscCs||S)zSame as a @ b.r8)r9r:r8r8r;r'lscCs| S)z Same as -a.r8)r9r8r8r;r,pscCs||BS)zSame as a | b.r8)r9r:r8r8r;r.tscCs| S)z Same as +a.r8)r9r8r8r;r/xscCs||S)zSame as a ** b.r8)r9r:r8r8r;r0|scCs||?S)zSame as a >> b.r8)r9r:r8r8r;r1scCs||S)zSame as a - b.r8)r9r:r8r8r;r3scCs||S)zSame as a / b.r8)r9r:r8r8r;r4scCs||AS)zSame as a ^ b.r8)r9r:r8r8r;r6scCs(t|ds dt|j}t|||S)z%Same as a + b, for a and b sequences. __getitem__z!'%s' object can't be concatenated)hasattrtype__name__ TypeError)r9r:msgr8r8r;rs cCs||kS)z(Same as b in a (note reversed operands).r8)r9r:r8r8r;rscCs&d}x|D]}||kr |d7}q W|S)z)Return the number of times b occurs in a.r7r8)r9r:countir8r8r;rs   cCs ||=dS)zSame as del a[b].Nr8)r9r:r8r8r;rscCs||S)z Same as a[b].r8)r9r:r8r8r;r scCs.x(t|D]\}}||kr |Sq WtddS)z!Return the first index of b in a.z$sequence.index(x): x not in sequenceN) enumerate ValueError)r9r:rFjr8r8r;rscCs |||<dS)zSame as a[b] = c.Nr8)r9r:cr8r8r;r2scCst|ts dt|j}t|yt|Stk r<YnXyt|j}Wntk r`|SXy ||}Wntk r|SX|tkr|St|tsdt|j}t||dkrd}t ||S)a2 Return an estimate of the number of items in obj. This is useful for presizing containers when building from an iterable. If the object supports len(), the result will be exact. Otherwise, it may over- or under-estimate by an arbitrary amount. The result will be an integer >= 0. z/'%s' object cannot be interpreted as an integerz'__length_hint__ must be integer, not %sr7z$__length_hint__() should return >= 0) isinstanceintr@rArBlen__length_hint__AttributeErrorNotImplementedrH)objdefaultrCZhintvalr8r8r;r$s4     c@s4eZdZdZd ZddZddZdd Zd d Zd S)raV Return a callable object that fetches the given attribute(s) from its operand. After f = attrgetter('name'), the call f(r) returns r.name. After g = attrgetter('name', 'date'), the call g(r) returns (r.name, r.date). After h = attrgetter('name.first', 'name.last'), the call h(r) returns (r.name.first, r.name.last). _attrs_callcsn|s.funccstfddDS)Nc3s|]}|VqdS)Nr8).0getter)rQr8r; sz4attrgetter.__init__..func..)tuple)rQ)getters)rQr;rZs) rKstrrBrTsplitrUr^mapr)selfattrZattrsrZr8)r_rYr;__init__s     zattrgetter.__init__cCs |j|S)N)rU)rcrQr8r8r;__call__szattrgetter.__call__cCs$d|jj|jjdjtt|jfS)Nz %s.%s(%s)z, ) __class__ __module__ __qualname__joinrbreprrT)rcr8r8r;__repr__szattrgetter.__repr__cCs |j|jfS)N)rgrT)rcr8r8r; __reduce__szattrgetter.__reduce__N)rTrU) rArhri__doc__ __slots__rerfrlrmr8r8r8r;rs c@s4eZdZdZd ZddZddZdd Zd d Zd S)r z Return a callable object that fetches the given item(s) from its operand. After f = itemgetter(2), the call f(r) returns r[2]. After g = itemgetter(2, 5, 3), the call g(r) returns (r[2], r[5], r[3]) _itemsrUcsFs f|_fdd}||_n"f|_fdd}||_dS)Ncs|S)Nr8)rQ)itemr8r;rZsz!itemgetter.__init__..funccstfddDS)Nc3s|]}|VqdS)Nr8)r[rF)rQr8r;r]sz4itemgetter.__init__..func..)r^)rQ)items)rQr;rZs)rprU)rcrqrrrZr8)rqrrr;res  zitemgetter.__init__cCs |j|S)N)rU)rcrQr8r8r;rfszitemgetter.__call__cCs$d|jj|jjdjtt|jfS)Nz %s.%s(%s)z, )rgrhrArjrbrkrp)rcr8r8r;rl szitemgetter.__repr__cCs |j|jfS)N)rgrp)rcr8r8r;rm%szitemgetter.__reduce__N)rprU) rArhrirnrorerfrlrmr8r8r8r;r s  c@s4eZdZdZdZddZddZd d Zd d Zd S)r(z Return a callable object that calls the given method on its operand. After f = methodcaller('name'), the call f(r) returns r.name(). After g = methodcaller('name', 'date', foo=1), the call g(r) returns r.name('date', foo=1). _name_args_kwargscOsVt|dkrd}t||d}|d|_t|jts>td|dd|_||_dS)Nz9methodcaller needs at least one argument, the method namer7rDzmethod name must be a string)rMrBrsrKr`rtru)argskwargsrCrcr8r8r;re1s   zmethodcaller.__init__cCst||j|j|jS)N)rWrsrtru)rcrQr8r8r;rf<szmethodcaller.__call__cCsTt|jg}|jtt|j|jdd|jjDd|jj|jj dj |fS)Ncss|]\}}d||fVqdS)z%s=%rNr8)r[kvr8r8r;r]Bsz(methodcaller.__repr__..z %s.%s(%s)z, ) rkrsextendrbrtrurrrgrhrArj)rcrwr8r8r;rl?s  zmethodcaller.__repr__cCsD|js|j|jf|jfSddlm}||j|jf|j|jfSdS)Nr7)partial)rurgrsrt functoolsr|)rcr|r8r8r;rmGs zmethodcaller.__reduce__N)rsrtru) rArhrirnrorerfrlrmr8r8r8r;r((s  cCs ||7}|S)zSame as a += b.r8)r9r:r8r8r;rQscCs ||M}|S)zSame as a &= b.r8)r9r:r8r8r;rVscCs,t|ds dt|j}t|||7}|S)z&Same as a += b, for a and b sequences.r>z!'%s' object can't be concatenated)r?r@rArB)r9r:rCr8r8r;r[s  cCs ||}|S)zSame as a //= b.r8)r9r:r8r8r;rcscCs ||K}|S)zSame as a <<= b.r8)r9r:r8r8r;rhscCs ||;}|S)zSame as a %= b.r8)r9r:r8r8r;rmscCs ||9}|S)zSame as a *= b.r8)r9r:r8r8r;rrscCs ||}|S)zSame as a @= b.r8)r9r:r8r8r;rwscCs ||O}|S)zSame as a |= b.r8)r9r:r8r8r;r|scCs ||C}|S)zSame as a **= b.r8)r9r:r8r8r;rscCs ||L}|S)zSame as a >>= b.r8)r9r:r8r8r;rscCs ||8}|S)zSame as a -= b.r8)r9r:r8r8r;rscCs ||}|S)zSame as a /= b.r8)r9r:r8r8r;r!scCs ||N}|S)zSame as a ^= b.r8)r9r:r8r8r;r"s)*)rnN)r7)irn__all__builtinsrr<r&r#r r+r r r-r5rrrrr rrrr%r)r*r'r,r.r/r0r1r3r4r6rrrrr rr2r$rr r(rrrrrrrrrrrrr!r" _operator ImportError__lt____le____eq____ne____ge____gt____not____abs____add____and__ __floordiv__r=__inv__ __invert__ __lshift____mod____mul__ __matmul____neg____or____pos____pow__ __rshift____sub__ __truediv____xor__ __concat__ __contains__ __delitem__r> __setitem____iadd____iand__ __iconcat__ __ifloordiv__ __ilshift____imod____imul__ __imatmul____ior____ipow__ __irshift____isub__ __itruediv____ixor__r8r8r8r; s    )')  dummy_threading.cpython-36.pyc000064400000002120151027002730012342 0ustar003 \ @sdZddlmZddlZdZdZdZzdekr:edZdZeded<dekr`edZ dZed=d ekrzed Z dZed =ddl Z eded <ed=ed ed <ed =dd l Tdd l m Z Wdere ed<[ [ere ed <[ [ereed<[ned=[[[XdS)aaFaux ``threading`` version using ``dummy_thread`` instead of ``thread``. The module ``_dummy_threading`` is added to ``sys.modules`` in order to not have ``threading`` considered imported. Had ``threading`` been directly imported it would have made all subsequent imports succeed regardless of whether ``_thread`` was available which is not desired. )modulesNF_threadT _dummy_thread threadingZ_threading_local_dummy_threadingZ_dummy__threading_local)*)__all__)__doc__sysrZ sys_modulesrZholding_threadZholding_threadingZholding__threading_localZ held_threadZheld_threadingZheld__threading_localrrrr r '/usr/lib64/python3.6/dummy_threading.pysP    nntplib.cpython-36.pyc000064400000101766151027002730010650 0ustar003 \F@sdZddlZddlZddlZddlZddlZy ddlZWnek rPdZYnXdZddl m Z ddlm Z ddd d d d d dgZ dZGdddeZGdd d eZGdd d eZGdd d eZGdd d eZGdd d eZdZdZddddddddd d!d"d#h Zd$d%d&d'd(d)d*gZd)d*d+Zd,Zejd-d.d/d0d1gZejd2d3d4d5gZd6dZ d7d8Zdld9d:Z dmd;d<Z!dnd=d>Z"erd?d@Z#GdAdBdBZ$GdCdde$Z%erGdDdEdEe$Z&e j'dEe(dFkrddl)Z)e)j*dGdHZ+e+j,dIdJdKdLdMe+j,dNdOdPdQdMe+j,dRdSdoe-dUeefdVe+j,dWdXdYe-dZdVe+j,d[d\d]dd^d_e+j.Z/e/j0Z0e/jse0dpkrteZ0e%e/j1e0d`Z2ne0dqkreZ0e&e/j1e0d`Z2e2j3Z4dae4kre2j5e2j6e/j6\Z7Z8Z9Z:Z;ee-e:e/j?dTZ9e2j@e9e:\Z7ZAxbeAD]Z\ZBZCe eCd%jDdhdTdZEe eCd$ZFe-eCd*ZGe>> from nntplib import NNTP >>> s = NNTP('news') >>> resp, count, first, last, name = s.group('comp.lang.python') >>> print('Group', name, 'has', count, 'articles, range', first, 'to', last) Group comp.lang.python has 51 articles, range 5770 to 5821 >>> resp, subs = s.xhdr('subject', '{0}-{1}'.format(first, last)) >>> resp = s.quit() >>> Here 'resp' is the server response line. Error responses are turned into exceptions. To post an article from a file: >>> f = open(filename, 'rb') # file containing article, including header >>> resp = s.post(f) >>> For descriptions of all methods, read the comments in the code below. Note that all arguments and return values representing article numbers are strings, not numbers, since they are rarely used for calculations. NFT) decode_header)_GLOBAL_DEFAULT_TIMEOUTNNTP NNTPErrorNNTPReplyErrorNNTPTemporaryErrorNNTPPermanentErrorNNTPProtocolError NNTPDataErrorric@seZdZdZddZdS)rz%Base class for all nntplib exceptionsc Gs>tj|f|y|d|_Wntk r8d|_YnXdS)NrzNo response given) Exception__init__response IndexError)selfargsr/usr/lib64/python3.6/nntplib.pyr bs zNNTPError.__init__N)__name__ __module__ __qualname____doc__r rrrrr`sc@seZdZdZdS)rzUnexpected [123]xx replyN)rrrrrrrrrisc@seZdZdZdS)rz 4xx errorsN)rrrrrrrrrmsc@seZdZdZdS)rz 5xx errorsN)rrrrrrrrrqsc@seZdZdZdS)r z"Response does not begin with [1-5]N)rrrrrrrrr usc@seZdZdZdS)r zError in response dataN)rrrrrrrrr yswi3Z100Z101211215Z220Z221Z222Z224Z225Z230Z231Z282subjectfromdatez message-idZ referencesz:bytesz:lines)bytesliness GroupInfogrouplastfirstflag ArticleInfoZnumber message_idrcCsNg}x>t|D]2\}}t|tr6|j|j|p.dq|j|qWdj|S)zvTakes a unicode string representing a munged header value and decodes it as a (possibly non-ASCII) readable value.ascii)_email_decode_header isinstancerappenddecodejoin)Z header_strpartsvencrrrrs  cCsg}xh|D]`}|ddkr<|ddjd\}}}d|}n|jd\}}}|j}tj||}|j|q Wt}t|t|krtd|dt||krtd|S)zParse a list of string representing the response to LIST OVERVIEW.FMT and return a list of header/metadata names. Raises NNTPDataError if the response is not compliant (cf. RFC 3977, section 8.4).r:Nz$LIST OVERVIEW.FMT response too shortz*LIST OVERVIEW.FMT redefines default fields) partitionlower_OVERVIEW_FMT_ALTERNATIVESgetr*_DEFAULT_OVERVIEW_FMTlenr )rfmtlinename_suffixZdefaultsrrr_parse_overview_fmts    r=cCstt}g}x|D]}i}|jd^}}t|}xt|D]\} } | t|krPq:|| } | jd} | |kr| r| d} | r| dt| j| krtd| r| t| dnd} | ||| <q:W|j||fqW|S)zZParse the response to an OVER or XOVER command according to the overview format `fmt`. r0z: Nz?OVER/XOVER response doesn't include names of additional headers) r7r6splitint enumerate startswithr3r r*)rr8Zdata_process_funcZ n_defaultsZoverviewr9ZfieldsZarticle_numbertokensitokenZ field_nameZ is_metadatahrrr_parse_overviews&   rGcCs|dkr |d d}|dd }t|dd}t|dd}t|dd}t|dd }t|d d }t|dd}|dkr|d7}n|dkr|d7}tj||||||S)zParse a pair of (date, time) strings, and return a datetime object. If only the date is given, it is assumed to be date and time concatenated together (e.g. response to the DATE command). NFidiliirMrN)r@datetime)date_strtime_strZhoursZminutesZsecondsyearZmonthZdayrrr_parse_datetimes   rScCsPt|tjsd}n dj|}|j}|r<|d}dj||}n dj||}||fS)aPFormat a date or datetime object as a pair of (date, time) strings in the format required by the NEWNEWS and NEWGROUPS commands. If a date object is passed, the time is assumed to be midnight (00h00). The returned representation depends on the legacy flag: * if legacy is False (the default): date has the YYYYMMDD format and time the HHMMSS format * if legacy is True: date has the YYMMDD format and time the HHMMSS format. RFC 3977 compliant servers should understand both formats; therefore, legacy is only needed when talking to old servers. Z000000z({0.hour:02d}{0.minute:02d}{0.second:02d}rLz{0:02d}{1.month:02d}{1.day:02d}z{0:04d}{1.month:02d}{1.day:02d})r)rOformatrR)ZdtZlegacyrQyrPrrr_unparse_datetimes   rVcCs|dkrtj}|j||dS)zWrap a socket in SSL/TLS. Arguments: - sock: Socket to wrap - context: SSL context to use for the encrypted connection Returns: - sock: New, encrypted socket. N)Zserver_hostname)sslZ_create_stdlib_contextZ wrap_socket)sockcontextZhostnamerrr _encrypt_onsrZc@seZdZdZdZdefddZddZdd Zd d Z d d Z ddZ e Z ddZ ddZdhddZddZdiddZddZdjddZdkdd Zd!d"Zd#d$Zd%d&Zdd'd(d)Zdd'd*d+Zdldd'd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zdd'd6d7Zd8d9Z d:d;Z!dmdd?Z#d@dAZ$dndBdCZ%dodd'dDdEZ&dpdd'dFdGZ'dqdd'dHdIZ(dJdKZ)dd'dLdMZ*dd'dNdOZ+dd'dPdQZ,dd'dRdSZ-dTdUZ.dVdWZ/dXdYZ0dZd[Z1d\d]Z2d^d_Z3d`daZ4drdbdcZ5dddeZ6e7rdsdfdgZ8dS)t _NNTPBasezutf-8surrogateescapeNcCsj||_||_d|_|j|_d|_|jd|_|rZd|jkrZ|j|jsZd|_|jd|_ d|_ dS)aSInitialize an instance. Arguments: - file: file-like object (open for read/write in binary mode) - host: hostname of the server - readermode: if true, send 'mode reader' command after connecting. - timeout: timeout (in seconds) used for socket connections readermode is sometimes necessary if you are connecting to an NNTP server on the local machine and intend to call reader-specific commands, such as `group'. If you get unexpected NNTPPermanentErrors, you might need to set readermode. rNFREADER) hostfile debugging_getrespwelcome_capsgetcapabilitiesreadermode_afterauth_setreadermodetls_on authenticated)rr_r^ readermodetimeoutrrrr 8s  z_NNTPBase.__init__cCs|S)Nr)rrrr __enter__gsz_NNTPBase.__enter__csRfdd}|rNz*y jWnttfk r8YnXWd|rLjXdS)Ncs tdS)Nr_)hasattrr)rrrksz$_NNTPBase.__exit__..)quitOSErrorEOFError_close)rrZ is_connectedr)rr__exit__js   z_NNTPBase.__exit__cCs|jrtdt|j|jS)zGet the welcome message from the server (this is read and squirreled away by __init__()). If the response code is 200, posting is allowed; if it 201, posting is not allowed.z *welcome*)r`printreprrb)rrrr getwelcomeusz_NNTPBase.getwelcomec Cs|jdkrd|_d|_y|j\}}Wnttfk rDi|_Ynsz,_NNTPBase._longcmdstring..)rr)rr9r_r|listr)rr_longcmdstrings  z_NNTPBase._longcmdstringcCsby|jStk rYnXy|jd\}}Wn tk rNtdd}Yn Xt|}||_|S)zqInternal: get the overview format. Queries the server if not already done, else returns the cached value.zLIST OVERVIEW.FMTN)Z_cachedoverviewfmtAttributeErrorrrr6r=)rr|rr8rrr_getoverviewfmtsz_NNTPBase._getoverviewfmtcCsdd|DS)NcSsg|]}t|jqSr)rr?)rr9rrrr$sz(_NNTPBase._grouplist..r)rrrrr _grouplist"sz_NNTPBase._grouplistcCs<i}|jd\}}x |D]}|j^}}|||<qW||fS)a!Process a CAPABILITIES command. Not supported by all servers. Return: - resp: server response if successful - caps: a dictionary mapping capability names to lists of tokens (for example {'VERSION': ['2'], 'OVER': [], LIST: ['ACTIVE', 'HEADERS'] }) Z CAPABILITIES)rr?)rr}r|rr9r:rCrrrry&s    z_NNTPBase.capabilities)r_cCsbt|tjtjfs$tdj|jjt||jdk\}}dj||}|j ||\}}||j |fS)zProcess a NEWGROUPS command. Arguments: - date: a date or datetime object Return: - resp: server response if successful - list: list of newsgroup names zAthe date parameter must be a date or datetime object, not '{:40}'rIzNEWGROUPS {0} {1}) r)rOr TypeErrorrT __class__rrVrxrr)rrr_rPrQcmdr|rrrr newgroups4s  z_NNTPBase.newgroupscCsRt|tjtjfs$tdj|jjt||jdk\}}dj|||}|j ||S)zProcess a NEWNEWS command. Arguments: - group: group name or '*' - date: a date or datetime object Return: - resp: server response if successful - list: list of message ids zAthe date parameter must be a date or datetime object, not '{:40}'rIzNEWNEWS {0} {1} {2}) r)rOrrrTrrrVrxr)rr rr_rPrQrrrrnewnewsDs z_NNTPBase.newnewscCs4|dk rd|}nd}|j||\}}||j|fS)a@Process a LIST or LIST ACTIVE command. Arguments: - group_pattern: a pattern indicating which groups to query - file: Filename string or file object to store the result in Returns: - resp: server response if successful - list: list of (group, last, first, flag) (strings) Nz LIST ACTIVE ZLIST)rr)r group_patternr_commandr|rrrrrTs  z_NNTPBase.listc Cstjd}|jd|\}}|jds8|jd|\}}i}x>|D]6}|j|j}|rB|jdd\} } |sp| S| || <qBW|r||fSdSdS)Nz^(?P[^ ]+)[ ]+(.*)$zLIST NEWSGROUPS rzXGTITLE r1rIr')recompilerrBsearchstripr ) rrZ return_allline_patr|rgroupsraw_linematchr:Zdescrrr_getdescriptionscs    z_NNTPBase._getdescriptionscCs |j|dS)aGet a description for a single group. If more than one group matches ('group' is a pattern), return the first. If no group matches, return an empty string. This elides the response code from the server, since it can only be '215' or '285' (for xgtitle) anyway. If the response code is needed, use the 'descriptions' method. NOTE: This neither checks for a wildcard in 'group' nor does it check whether the group actually exists.F)r)rr rrr descriptionzs z_NNTPBase.descriptioncCs |j|dS)z'Get descriptions for a range of groups.T)r)rrrrr descriptionssz_NNTPBase.descriptionscCs|jd|}|jds t||j}d}}}t|}|dkr|d}|dkr|d}|dkr|d}|dkr|dj}|t|t|t||fS)aProcess a GROUP command. Argument: - group: the group name Returns: - resp: server response if successful - count: number of articles - first: first article number - last: last article number - name: the group name zGROUP rrr1rIrrJ)rrBrr?r7r3r@)rr:r|wordscountr"r!nrrrr s    z_NNTPBase.groupcCs |jd|S)aProcess a HELP command. Argument: - file: Filename string or file object to store the result in Returns: - resp: server response if successful - list: list of strings returned by the server in response to the HELP command ZHELP)r)rr_rrrhelpsz_NNTPBase.helpcCs8|jdst||j}t|d}|d}|||fS)z_Internal: parse the response line of a STAT, NEXT, LAST, ARTICLE, HEAD or BODY command.Z22r1rI)rBrr?r@)rr|rart_numr%rrr _statparses   z_NNTPBase._statparsecCs|j|}|j|S)z/Internal: process a STAT, NEXT or LAST command.)rr)rr9r|rrr_statcmds z_NNTPBase._statcmdcCs"|r|jdj|S|jdSdS)a(Process a STAT command. Argument: - message_spec: article number or message id (if not specified, the current article is selected) Returns: - resp: server response if successful - art_num: the article number - message_id: the message id zSTAT {0}ZSTATN)rrT)r message_specrrrstats z_NNTPBase.statcCs |jdS)z;Process a NEXT command. No arguments. Return as for STAT.ZNEXT)r)rrrrnextsz_NNTPBase.nextcCs |jdS)z;Process a LAST command. No arguments. Return as for STAT.ZLAST)r)rrrrr!sz_NNTPBase.lastcCs0|j||\}}|j|\}}}|t|||fS)z2Internal: process a HEAD, BODY or ARTICLE command.)rrr$)rr9r_r|rrr%rrr_artcmdsz_NNTPBase._artcmdcCs$|dk rdj|}nd}|j||S)a0Process a HEAD command. Argument: - message_spec: article number or message id - file: filename string or file object to store the headers in Returns: - resp: server response if successful - ArticleInfo: (article number, message id, list of header lines) NzHEAD {0}ZHEAD)rTr)rrr_rrrrheads z_NNTPBase.headcCs$|dk rdj|}nd}|j||S)a+Process a BODY command. Argument: - message_spec: article number or message id - file: filename string or file object to store the body in Returns: - resp: server response if successful - ArticleInfo: (article number, message id, list of body lines) NzBODY {0}ZBODY)rTr)rrr_rrrrbodys z_NNTPBase.bodycCs$|dk rdj|}nd}|j||S)a5Process an ARTICLE command. Argument: - message_spec: article number or message id - file: filename string or file object to store the article in Returns: - resp: server response if successful - ArticleInfo: (article number, message id, list of article lines) Nz ARTICLE {0}ZARTICLE)rTr)rrr_rrrrarticles z_NNTPBase.articlecCs |jdS)zYProcess a SLAVE command. Returns: - resp: server response if successful ZSLAVE)r)rrrrslavesz_NNTPBase.slavecsDtjd|jdj|||\}}fdd|fdd|DfS)aiProcess an XHDR command (optional server extension). Arguments: - hdr: the header type (e.g. 'subject') - str: an article nr, a message id, or a range nr1-nr2 - file: Filename string or file object to store the result in Returns: - resp: server response if successful - list: list of (nr, value) strings z^([0-9]+) ?(.*) ?z XHDR {0} {1}csj|}|r|jddS|S)Nr1rI)rr )r9m)patrr remove_numbers z%_NNTPBase.xhdr..remove_numbercsg|] }|qSrr)rr9)rrrrsz"_NNTPBase.xhdr..)rrrrT)rZhdrrr_r|rr)rrrxhdr s  z_NNTPBase.xhdrcCs.|jdj|||\}}|j}|t||fS)aFProcess an XOVER command (optional server extension) Arguments: - start: start of range - end: end of range - file: Filename string or file object to store the result in Returns: - resp: server response if successful - list: list of dicts containing the response fields z XOVER {0}-{1})rrTrrG)rstartendr_r|rr8rrrxovers  z_NNTPBase.xoverc Csxd|jkrdnd}t|ttfr>|\}}|dj||p6d7}n|dk rR|d|}|j||\}}|j}|t||fS)aProcess an OVER command. If the command isn't supported, fall back to XOVER. Arguments: - message_spec: - either a message id, indicating the article to fetch information about - or a (start, end) tuple, indicating a range of article numbers; if end is None, information up to the newest message will be retrieved - or None, indicating the current article number must be used - file: Filename string or file object to store the result in Returns: - resp: server response if successful - list: list of dicts containing the response fields NOTE: the "message id" form isn't supported by XOVER ZOVERZXOVERz {0}-{1}r'Nrw)rcr)tuplerrTrrrG) rrr_rrrr|rr8rrrover(s z_NNTPBase.overc Csjtjdtdtjd}|jd||\}}g}x0|D](}|j|j}|r6|j|j ddq6W||fS)zProcess an XGTITLE command (optional server extension) Arguments: - group: group name wildcard (i.e. news.*) Returns: - resp: server response if successful - list: list of (name,title) stringszFThe XGTITLE extension is not actively used, use descriptions() insteadrIz^([^ ]+)[ ]+(.*)$zXGTITLE r1) warningswarnDeprecationWarningrrrrrr*r ) rr r_rr|Z raw_linesrrrrrrxgtitleCs  z_NNTPBase.xgtitlec Csjtjdtd|jdj|}|jds0t|y|j\}}Wntk r\t|Yn X||fSdS)zProcess an XPATH command (optional server extension) Arguments: - id: Message id of article Returns: resp: server response if successful path: directory path to article z(The XPATH extension is not actively usedrIz XPATH {0}Z223N) rrrrrTrBrr? ValueError)ridr|Zresp_numpathrrrxpathUs z_NNTPBase.xpathcCsb|jd}|jdst||j}t|dkr8t||d}t|dkrTt||t|dfS)zProcess the DATE command. Returns: - resp: server response if successful - date: datetime object ZDATEZ111rIr1N)rrBrr?r7r rS)rr|elemrrrrris    z_NNTPBase.datecCs|j|}|jdst|t|ttfr2|j}xB|D]:}|jtsT|j dt}|jdrfd|}|j j |q8W|j j d|j j |j S)N3s rs. )rrBrr)r bytearray splitlinesendswithrrstripr_rrra)rrfr|r9rrr_postzs       z_NNTPBase._postcCs |jd|S)zProcess a POST command. Arguments: - data: bytes object, iterable or file containing the article Returns: - resp: server response if successfulZPOST)r)rdatarrrpostsz_NNTPBase.postcCs|jdj||S)a Process an IHAVE command. Arguments: - message_id: message-id of the article - data: file containing the article Returns: - resp: server response if successful Note that if the server refuses the article an exception is raised.z IHAVE {0})rrT)rr%rrrrihavesz_NNTPBase.ihavecCs|jj|`dS)N)r_r)rrrrrqs z_NNTPBase._closec Csz|jd}Wd|jX|S)zdProcess a QUIT command and close the socket. Returns: - resp: server response if successfulZQUITN)rrq)rr|rrrrns z_NNTPBase.quitc Cs|jrtd| r"| r"tdy>|r^| r^ddl}|j}|j|j}|r^|d}|d}Wntk rtYnX|s~dS|jd|}|jdr|st|n |jd|}|jdst |d|_ |j |j rd |j kr|j d|_ |j dS) NzAlready logged in.z7At least one of `user` and `usenetrc` must be specifiedrrIzauthinfo user Z381zauthinfo pass Z281r])rhrnetrcZauthenticatorsr^rorrBrrrcrdrerf)ruserpasswordusenetrcrZ credentialsZauthr|rrrlogins<       z_NNTPBase.logincCs`y|jd|_WnJtk r$Yn8tk rZ}z|jjdrHd|_nWYdd}~XnXdS)Nz mode readerZ480T)rrbrrr rBre)rerrrrfs z_NNTPBase._setreadermodecCs||jrtd|jrtd|jd}|jdrp|jjt|j||j |_|jj d|_d|_d|_ |j nt ddS) zzProcess a STARTTLS command. Arguments: - context: SSL context to use for the encrypted connection zTLS is already enabled.z+TLS cannot be started after authentication.STARTTLSZ382rwbTNzTLS failed to start.)rgrrhrrBr_rrZrXr^makefilercrdr)rrYr|rrrstarttlss    z_NNTPBase.starttls)T)N)N)N)N)N)N)N)N)N)NNT)N)9rrrrrrr rkrrrurdrdebugrrrrarrrrrrryrrrrrrr rrrrrr!rrrrrrrrrrrrrrrqrnrrf _have_sslrrrrrr[(sj .    .         ) r[c@s*eZdZeddddefddZddZdS)rNFc Cs||_||_tj||f||_d}y8|jjd}tj||||||sJ|rX|j|||Wn$|rn|j |jj YnXdS)a,Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port) - user: username to authenticate with - password: password to use with username - readermode: if true, send 'mode reader' command after connecting. - usenetrc: allow loading username and password from ~/.netrc file if not specified explicitly - timeout: timeout (in seconds) used for socket connections readermode is sometimes necessary if you are connecting to an NNTP server on the local machine and intend to call reader-specific commands, such as `group'. If you get unexpected NNTPPermanentErrors, you might need to set readermode. Nr) r^portsocketcreate_connectionrXrr[r rr) rr^rrrrirrjr_rrrr s   z NNTP.__init__c Cs ztj|Wd|jjXdS)N)r[rqrXr)rrrrrq!sz NNTP._close)rrr NNTP_PORTrr rqrrrrrs "c@s,eZdZedddddefddZddZdS)NNTP_SSLNFc Cstj||f||_d} yJt|j|||_|jjd} tj|| |||d|sP|r^|j|||Wn$| rt| j|jjYnXdS)zThis works identically to NNTP.__init__, except for the change in default port and the `ssl_context` argument for SSL connections. Nr)rirj) rrrXrZrr[r rr) rr^rrrZ ssl_contextrirrjr_rrrr +s    zNNTP_SSL.__init__c Cs ztj|Wd|jjXdS)N)r[rqrXr)rrrrrqAszNNTP_SSL._close)rrr NNTP_SSL_PORTrr rqrrrrr)s  r__main__zJ nntplib built-in demo - display the latest articles in a newsgroup)rz-gz--groupzgmane.comp.python.generalz3group to fetch messages from (default: %(default)s))defaultrz-sz--serverznews.gmane.orgz+NNTP server hostname (default: %(default)s)z-pz--portr1z#NNTP port number (default: %s / %s))rtyperz-nz --nb-articles z2number of articles to fetch (default: %(default)s)z-Sz--ssl store_truezuse NNTP over SSL)actionrr)r^rrZGroupZhaszarticles, rangeZtocCs$t||kr |d|dd}|S)NrJz...)r7)sZlimrrrcutls rs&          X-             pickletools.cpython-36.opt-1.pyc000064400000177223151027002730012472 0ustar003 \fI@s dZddlZddlZddlZddlZddlZdddgZejZdZdZ dZ dZ dZ Gd d d e Zdd lmZddZeddeddZddZeddeddZddZedd eddZddZedd eddZdd Zed!d"ed#dZdd%d&Zed'eed(dZd)d*Zed+eed,dZd-d.Z ed/ee d0dZ!d1d2Z"ed3e e"d4dZ#d5d6Z$ed7e e$d8dZ%d9d:Z&ed;e e&ddZ'd?d@Z(edAe e(dBdZ)dCdDZ*edEe e*dFdZ+dGdHZ,edIee,dJdZ-dKdLZ.edMe e.dNdZ/dOdPZ0edQe e0dRdZ1dSdTZ2edUe e2dVdZ3dWdXZ4dYdZZ5ed[ee4d\dZ6ed]ee5d^dZ7d_d`Z8edaee8dbdZ9dcddZ:eded"e:dfdZ;ddglmdldmZ?edne e?dodZ@Gdpdqdqe ZAeAdreBdsdtZCZDeAdueBeEfdvdtZFeAdweEdxdtZGeAdyeHdzdtZIeAd{eJeKfd|dtZLZMeAd}eJd~dtZNeAdeKddtZOeAdePdddtZQeAdeRddtZSeAdeTddtZUeAdeVddtZWeAdeXddtZYeAdeXddtZZeAde ddtZ[eAdeAddtZ\eAdeAddtZ]Gddde Z^e^Z_e_dde6geFgddde_ddegeCgddde_ddegeCgddde_ddegeCgddde_dde7geCgddde_dde>geCgddde_dde@geCgddde_ddegeLgddde_dde%geLgddde_dde#geLgddde_dde)geNgddde_dde'geNgddde_dde+geNgd dde_dddgeQgddde_dddgeGgddde_dddgeGgddde_dde-geOgddde_dde/geOgd dde_dde1geOgddde_dde3geOgd dde_dde9geIgddde_dde;geIgddde_dddgeUgddde_dddeUe[geUgddde_dddeUe\e]geUgddde_ddde\e]geUgddde_dddgeSgddde_ddde\e]geSgddde_ddde[geSgddde_ddde[e[geSgddde_ddde[e[e[geSgddde_dddgeWgddde_ddde\e]geWgddde_dddeWe[e[geWgddde_dddeWe\e]geWgddde_dddgeYgd dde_dddeYe\e]geYgd dde_ddde\e]geZgd dde_dd de[ggdd de_d d de[ge[e[gdd de_dddge\gddde_ddde\e]ggddde_dde6ge[gddde_ddege[gddde_ddege[gddde_dde6ggddde_d d!eggdd"de_d#d$eggdd%de_d&d'de[ge[gd d(de_d)d*ege[gdd+de_d,d-ege[gdd.de_d/d0ege[gdd1de_d2d3e!ge[gdd4de_d5d6deOeOge[gd d7de_d8d9de[e[ge[gdd:de_d;dd?e!e\e]ge[gdd@de_dAdBde\e[e]ge[gddCde_dDdEde[e[ge[gddFde_dGdHde[e[e[ge[gd dIde_dJdKeggddLde_dMdNde[ggddOde_dPdQeggd dRde_dSdTege[gddUde_dVdWde[ge[gddXdgAZ`[_iZaiZbxzece`D]n\ZdZeeejfeak regdYeejfeaeejfedfeejhebk regdZeejhebeejhedfedeaeejf<edebeejh< qW[a[b[d[eiZixe`D]Zeeeeieejh< qW[edd\d]Zjej[jdd^d_Zkd`dZldadZmddbdZnGdcddddZodeZpdfZqepeqdgZrdhdiZsetdjk rddluZueujvdkdlZwewjxdmeujydndodpdqewjxdrdsejzeujydtdudvewjxdwdxdydzd{ewjxd|d}d eBd~dvewjxdddydd{ewjxdddddewjxdddydd{ewjxddydd{ewj{Z|e|j} resne|j~ rdndZ~e|j sewjnee|jdk r*ene|jde|jde|je~nZe|j r6indZxHe|jD]>Ze|jjejfdZe|jjedenee|jee|je~ qBWdS(ar"Executable documentation" for the pickle module. Extensive comments about the pickle protocols and pickle-machine opcodes can be found here. Some functions meant for external use: genops(pickle) Generate all the opcodes in a pickle, as (opcode, arg, position) triples. dis(pickle, out=None, memo=None, indentlevel=4) Print a symbolic disassembly of a pickle. Ndisgenopsoptimizec@seZdZdZddZdS) ArgumentDescriptornamenreaderdoccCs||_||_||_||_dS)N)r r r r)selfr r r rr#/usr/lib64/python3.6/pickletools.py__init__szArgumentDescriptor.__init__N)r r r r)__name__ __module__ __qualname__ __slots__rrrrrr s r )unpackcCs"|jd}|r|dStddS)zG >>> import io >>> read_uint1(io.BytesIO(b'\xff')) 255 rrz'not enough data in stream to read uint1N)read ValueError)fdatarrr read_uint1s ruint1zOne-byte unsigned integer.)r r r rcCs0|jd}t|dkr$td|dStddS)z >>> import io >>> read_uint2(io.BytesIO(b'\xff\x00')) 255 >>> read_uint2(io.BytesIO(b'\xff\xff')) 65535 rz>> import io >>> read_int4(io.BytesIO(b'\xff\x00\x00\x00')) 255 >>> read_int4(io.BytesIO(b'\x00\x00\x00\x80')) == -(2**31) True rz>> import io >>> read_uint4(io.BytesIO(b'\xff\x00\x00\x00')) 255 >>> read_uint4(io.BytesIO(b'\x00\x00\x00\x80')) == 2**31 True rz>> import io >>> read_uint8(io.BytesIO(b'\xff\x00\x00\x00\x00\x00\x00\x00')) 255 >>> read_uint8(io.BytesIO(b'\xff' * 8)) == 2**64-1 True z>> import io >>> read_stringnl(io.BytesIO(b"'abcd'\nefg\n")) 'abcd' >>> read_stringnl(io.BytesIO(b"\n")) Traceback (most recent call last): ... ValueError: no string quotes around b'' >>> read_stringnl(io.BytesIO(b"\n"), stripquotes=False) '' >>> read_stringnl(io.BytesIO(b"''\n")) '' >>> read_stringnl(io.BytesIO(b'"abcd"')) Traceback (most recent call last): ... ValueError: no newline found when trying to read stringnl Embedded escapes are undone in the result. >>> read_stringnl(io.BytesIO(br"'a\n\\b\x00c\td'" + b"\n'e'")) 'a\n\\b\x00c\td'  z-no newline found when trying to read stringnlNr"'z,strinq quote %r not found at both ends of %rzno string quotes around %rrascii)r*r+r-)readlineendswithr startswithcodecs escape_decodedecode)rr3 stripquotesrqrrr read_stringnl;s         r6stringnlzA newline-terminated string. This is a repr-style string, with embedded escapes, and bracketing quotes. cCs t|ddS)NF)r4)r6)rrrrread_stringnl_noescapetsr8stringnl_noescapeaA newline-terminated string. This is a str-style string, without embedded escapes, or bracketing quotes. It should consist solely of printable ASCII characters. cCsdt|t|fS)zp >>> import io >>> read_stringnl_noescape_pair(io.BytesIO(b"Queue\nEmpty\njunk")) 'Queue Empty' z%s %s)r8)rrrrread_stringnl_noescape_pairsr:stringnl_noescape_pairaA pair of newline-terminated strings. These are str-style strings, without embedded escapes, or bracketing quotes. They should consist solely of printable ASCII characters. The pair is returned as a single string, with a single blank separating the two strings. cCs@t|}|j|}t||kr(|jdStd|t|fdS)z >>> import io >>> read_string1(io.BytesIO(b"\x00")) '' >>> read_string1(io.BytesIO(b"\x03abcdef")) 'abc' zlatin-1z2expected %d bytes in a string1, but only %d remainN)rrrr3r)rr rrrr read_string1s    r<string1zA counted string. The first argument is a 1-byte unsigned int giving the number of bytes in the string, and the second argument is that many bytes. cCsTt|}|dkrtd||j|}t||kr<|jdStd|t|fdS)aP >>> import io >>> read_string4(io.BytesIO(b"\x00\x00\x00\x00abc")) '' >>> read_string4(io.BytesIO(b"\x03\x00\x00\x00abcdef")) 'abc' >>> read_string4(io.BytesIO(b"\x00\x00\x00\x03abcdef")) Traceback (most recent call last): ... ValueError: expected 50331648 bytes in a string4, but only 6 remain rzstring4 byte count < 0: %dzlatin-1z2expected %d bytes in a string4, but only %d remainN)r"rrrr3)rr rrrr read_string4s     r>string4zA counted string. The first argument is a 4-byte little-endian signed int giving the number of bytes in the string, and the second argument is that many bytes. cCs:t|}|j|}t||kr"|Std|t|fdS)z >>> import io >>> read_bytes1(io.BytesIO(b"\x00")) b'' >>> read_bytes1(io.BytesIO(b"\x03abcdef")) b'abc' z1expected %d bytes in a bytes1, but only %d remainN)rrrr)rr rrrr read_bytes1s   r@bytes1zA counted bytes string. The first argument is a 1-byte unsigned int giving the number of bytes in the string, and the second argument is that many bytes. cCs:t|}|j|}t||kr"|Std|t|fdS)z >>> import io >>> read_bytes1(io.BytesIO(b"\x00")) b'' >>> read_bytes1(io.BytesIO(b"\x03abcdef")) b'abc' z1expected %d bytes in a bytes1, but only %d remainN)rrrr)rr rrrrr@s   zA counted bytes string. The first argument is a 1-byte unsigned int giving the number of bytes, and the second argument is that many bytes. cCsPt|}|tjkrtd||j|}t||kr8|Std|t|fdS)aN >>> import io >>> read_bytes4(io.BytesIO(b"\x00\x00\x00\x00abc")) b'' >>> read_bytes4(io.BytesIO(b"\x03\x00\x00\x00abcdef")) b'abc' >>> read_bytes4(io.BytesIO(b"\x00\x00\x00\x03abcdef")) Traceback (most recent call last): ... ValueError: expected 50331648 bytes in a bytes4, but only 6 remain z#bytes4 byte count > sys.maxsize: %dz1expected %d bytes in a bytes4, but only %d remainN)r$sysmaxsizerrr)rr rrrr read_bytes4s     rDbytes4zA counted bytes string. The first argument is a 4-byte little-endian unsigned int giving the number of bytes, and the second argument is that many bytes. cCsPt|}|tjkrtd||j|}t||kr8|Std|t|fdS)a >>> import io, struct, sys >>> read_bytes8(io.BytesIO(b"\x00\x00\x00\x00\x00\x00\x00\x00abc")) b'' >>> read_bytes8(io.BytesIO(b"\x03\x00\x00\x00\x00\x00\x00\x00abcdef")) b'abc' >>> bigsize8 = struct.pack(">> read_bytes8(io.BytesIO(bigsize8 + b"abcdef")) #doctest: +ELLIPSIS Traceback (most recent call last): ... ValueError: expected ... bytes in a bytes8, but only 6 remain z#bytes8 byte count > sys.maxsize: %dz1expected %d bytes in a bytes8, but only %d remainN)r'rBrCrrr)rr rrrr read_bytes83s    rFbytes8zA counted bytes string. The first argument is an 8-byte little-endian unsigned int giving the number of bytes, and the second argument is that many bytes. cCs0|j}|jdstd|dd}t|dS)zm >>> import io >>> read_unicodestringnl(io.BytesIO(b"abc\\uabcd\njunk")) == 'abc\uabcd' True r)z4no newline found when trying to read unicodestringnlNrzraw-unicode-escaper-)r.r/rstr)rrrrrread_unicodestringnlUs   rIunicodestringnlzA newline-terminated Unicode string. This is raw-unicode-escape encoded, so consists of printable ASCII characters, and may contain embedded escape sequences. cCsBt|}|j|}t||kr*t|ddStd|t|fdS)a >>> import io >>> s = 'abcd\uabcd' >>> enc = s.encode('utf-8') >>> enc b'abcd\xea\xaf\x8d' >>> n = bytes([len(enc)]) # little-endian 1-byte length >>> t = read_unicodestring1(io.BytesIO(n + enc + b'junk')) >>> s == t True >>> read_unicodestring1(io.BytesIO(n + enc[:-1])) Traceback (most recent call last): ... ValueError: expected 7 bytes in a unicodestring1, but only 6 remain zutf-8 surrogatepassz9expected %d bytes in a unicodestring1, but only %d remainN)rrrrHr)rr rrrrread_unicodestring1os    rLunicodestring1aAA counted Unicode string. The first argument is a 1-byte little-endian signed int giving the number of bytes in the string, and the second argument-- the UTF-8 encoding of the Unicode string -- contains that many bytes. cCsXt|}|tjkrtd||j|}t||kr@t|ddStd|t|fdS)a >>> import io >>> s = 'abcd\uabcd' >>> enc = s.encode('utf-8') >>> enc b'abcd\xea\xaf\x8d' >>> n = bytes([len(enc), 0, 0, 0]) # little-endian 4-byte length >>> t = read_unicodestring4(io.BytesIO(n + enc + b'junk')) >>> s == t True >>> read_unicodestring4(io.BytesIO(n + enc[:-1])) Traceback (most recent call last): ... ValueError: expected 7 bytes in a unicodestring4, but only 6 remain z+unicodestring4 byte count > sys.maxsize: %dzutf-8rKz9expected %d bytes in a unicodestring4, but only %d remainN)r$rBrCrrrrH)rr rrrrread_unicodestring4s     rNunicodestring4aAA counted Unicode string. The first argument is a 4-byte little-endian signed int giving the number of bytes in the string, and the second argument-- the UTF-8 encoding of the Unicode string -- contains that many bytes. cCsXt|}|tjkrtd||j|}t||kr@t|ddStd|t|fdS)a >>> import io >>> s = 'abcd\uabcd' >>> enc = s.encode('utf-8') >>> enc b'abcd\xea\xaf\x8d' >>> n = bytes([len(enc)]) + b'\0' * 7 # little-endian 8-byte length >>> t = read_unicodestring8(io.BytesIO(n + enc + b'junk')) >>> s == t True >>> read_unicodestring8(io.BytesIO(n + enc[:-1])) Traceback (most recent call last): ... ValueError: expected 7 bytes in a unicodestring8, but only 6 remain z+unicodestring8 byte count > sys.maxsize: %dzutf-8rKz9expected %d bytes in a unicodestring8, but only %d remainN)r'rBrCrrrrH)rr rrrrread_unicodestring8s     rPunicodestring8aBA counted Unicode string. The first argument is an 8-byte little-endian signed int giving the number of bytes in the string, and the second argument-- the UTF-8 encoding of the Unicode string -- contains that many bytes. cCs.t|ddd}|dkrdS|dkr&dSt|S)z >>> import io >>> read_decimalnl_short(io.BytesIO(b"1234\n56")) 1234 >>> read_decimalnl_short(io.BytesIO(b"1234L\n56")) Traceback (most recent call last): ... ValueError: invalid literal for int() with base 10: b'1234L' F)r3r4s00s01T)r6int)rsrrrread_decimalnl_shorts rTcCs2t|ddd}|dddkr*|dd}t|S)z >>> import io >>> read_decimalnl_long(io.BytesIO(b"1234L\n56")) 1234 >>> read_decimalnl_long(io.BytesIO(b"123456789012345678901234L\n6")) 123456789012345678901234 F)r3r4rNLr-r-)r6rR)rrSrrrread_decimalnl_longs  rVdecimalnl_shortaA newline-terminated decimal integer literal. This never has a trailing 'L', and the integer fit in a short Python int on the box where the pickle was written -- but there's no guarantee it will fit in a short Python int on the box where the pickle is read. decimalnl_longzA newline-terminated decimal integer literal. This has a trailing 'L', and can represent integers of any size. cCst|ddd}t|S)zO >>> import io >>> read_floatnl(io.BytesIO(b"-1.25\n6")) -1.25 F)r3r4)r6float)rrSrrr read_floatnl'srZfloatnlaA newline-terminated decimal floating literal. In general this requires 17 significant digits for roundtrip identity, and pickling then unpickling infinities, NaNs, and minus zero doesn't work across boxes, or on some boxes even on itself (e.g., Windows can't read the strings it produces for infinities or NaNs). cCs0|jd}t|dkr$td|dStddS)z >>> import io, struct >>> raw = struct.pack(">d", -1.25) >>> raw b'\xbf\xf4\x00\x00\x00\x00\x00\x00' >>> read_float8(io.BytesIO(raw + b"\n")) -1.25 r&z>drz(not enough data in stream to read float8N)rrrr)rrrrr read_float8=s  r\float8aAn 8-byte binary representation of a float, big-endian. The format is unique to Python, and shared with the struct module (format string '>d') "in theory" (the struct and pickle implementations don't share the code -- they should). It's strongly related to the IEEE-754 double format, and, in normal cases, is in fact identical to the big-endian 754 double format. On other boxes the dynamic range is limited to that of a 754 double, and "add a half and chop" rounding is used to reduce the precision to 53 bits. However, even on a 754 box, infinities, NaNs, and minus zero may not be handled correctly (may not survive roundtrip pickling intact). ) decode_longcCs.t|}|j|}t||kr&tdt|S)a+ >>> import io >>> read_long1(io.BytesIO(b"\x00")) 0 >>> read_long1(io.BytesIO(b"\x02\xff\x00")) 255 >>> read_long1(io.BytesIO(b"\x02\xff\x7f")) 32767 >>> read_long1(io.BytesIO(b"\x02\x00\xff")) -256 >>> read_long1(io.BytesIO(b"\x02\x00\x80")) -32768 z'not enough data in stream to read long1)rrrrr^)rr rrrr read_long1cs   r_long1aA binary long, little-endian, using 1-byte size. This first reads one byte as an unsigned size, then reads that many bytes and interprets them as a little-endian 2's-complement long. If the size is 0, that's taken as a shortcut for the long 0L. cCsBt|}|dkrtd||j|}t||kr:tdt|S)ag >>> import io >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\xff\x00")) 255 >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\xff\x7f")) 32767 >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\x00\xff")) -256 >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\x00\x80")) -32768 >>> read_long1(io.BytesIO(b"\x00\x00\x00\x00")) 0 rzlong4 byte count < 0: %dz'not enough data in stream to read long4)r"rrrr^)rr rrrr read_long4s   ralong4aA binary representation of a long, little-endian. This first reads four bytes as a signed size (but requires the size to be >= 0), then reads that many bytes and interprets them as a little-endian 2's-complement long. If the size is 0, that's taken as a shortcut for the int 0, although LONG1 should really be used then instead (and in any case where # of bytes < 256). c@s eZdZd ZddZddZdS) StackObjectr obtypercCs.||_t|trx |D]}qW||_||_dS)N)r isinstancetuplerdr)rr rdrZ containedrrrrs   zStackObject.__init__cCs|jS)N)r )rrrr__repr__szStackObject.__repr__N)r rdr)rrrrrrgrrrrrcs  rcrRzA Python integer object.)r rdrZ int_or_boolz#A Python integer or boolean object.boolzA Python boolean object.rYzA Python float object.Z bytes_or_strz*A Python bytes or (Unicode) string object.byteszA Python bytes object.rHz!A Python (Unicode) string object.NonezThe Python None object.rfzA Python tuple object.listzA Python list object.dictzA Python dict object.setzA Python set object. frozensetzA Python frozenset object.anyzAny kind of object whatsoever.Zmarkaz'The mark' is a unique object. Opcodes that operate on a variable number of objects generally don't embed the count of objects in the opcode, or pull it off the stack. Instead the MARK opcode is used to push a special marker object on the stack, and then some other opcodes grab all the objects from the top of the stack down to (but not including) the topmost marker object. stacksliceaAn object representing a contiguous slice of the stack. This is used in conjunction with markobject, to represent all of the stack following the topmost markobject. For example, the POP_MARK opcode changes the stack from [..., markobject, stackslice] to [...] No matter how many object are on the stack after the topmost markobject, POP_MARK gets rid of all of them (including the topmost markobject too). c@seZdZd Zdd Zd S) OpcodeInfor codearg stack_before stack_afterprotorc CsJ||_||_||_x |D]}qW||_x |D]}q,W||_||_||_dS)N)r rrrsrtrurvr) rr rrrsrtrurvrxrrrrTs  zOpcodeInfo.__init__N)r rrrsrtrurvr)rrrrrrrrrrq5srqZINTIaPush an integer or bool. The argument is a newline-terminated decimal literal string. The intent may have been that this always fit in a short Python int, but INT can be generated in pickles written on a 64-bit box that require a Python long on a 32-bit box. The difference between this and LONG then is that INT skips a trailing 'L', and produces a short int whenever possible. Another difference is due to that, when bool was introduced as a distinct type in 2.3, builtin names True and False were also added to 2.2.2, mapping to ints 1 and 0. For compatibility in both directions, True gets pickled as INT + "I01\n", and False as INT + "I00\n". Leading zeroes are never produced for a genuine integer. The 2.3 (and later) unpicklers special-case these and return bool instead; earlier unpicklers ignore the leading "0" and return the int. )r rrrsrtrurvrZBININTJa1Push a four-byte signed integer. This handles the full range of Python (short) integers on a 32-bit box, directly as binary bytes (1 for the opcode and 4 for the integer). If the integer is non-negative and fits in 1 or 2 bytes, pickling via BININT1 or BININT2 saves space. ZBININT1KzPush a one-byte unsigned integer. This is a space optimization for pickling very small non-negative ints, in range(256). ZBININT2MzPush a two-byte unsigned integer. This is a space optimization for pickling small positive ints, in range(256, 2**16). Integers in range(256) can also be pickled via BININT2, but BININT1 instead saves a byte. ZLONGLaPush a long integer. The same as INT, except that the literal ends with 'L', and always unpickles to a Python long. There doesn't seem a real purpose to the trailing 'L'. Note that LONG takes time quadratic in the number of digits when unpickling (this is simply due to the nature of decimal->binary conversion). Proto 2 added linear-time (in C; still quadratic-time in Python) LONG1 and LONG4 opcodes. ZLONG1Šz|Long integer using one-byte length. A more efficient encoding of a Python long; the long1 encoding says it all.ZLONG4‹z~Long integer using found-byte length. A more efficient encoding of a Python long; the long4 encoding says it all.STRINGSaPush a Python string object. The argument is a repr-style string, with bracketing quote characters, and perhaps embedded escapes. The argument extends until the next newline character. These are usually decoded into a str instance using the encoding given to the Unpickler constructor. or the default, 'ASCII'. If the encoding given was 'bytes' however, they will be decoded as bytes object instead. Z BINSTRINGTaPush a Python string object. There are two arguments: the first is a 4-byte little-endian signed int giving the number of bytes in the string, and the second is that many bytes, which are taken literally as the string content. These are usually decoded into a str instance using the encoding given to the Unpickler constructor. or the default, 'ASCII'. If the encoding given was 'bytes' however, they will be decoded as bytes object instead. ZSHORT_BINSTRINGUaPush a Python string object. There are two arguments: the first is a 1-byte unsigned int giving the number of bytes in the string, and the second is that many bytes, which are taken literally as the string content. These are usually decoded into a str instance using the encoding given to the Unpickler constructor. or the default, 'ASCII'. If the encoding given was 'bytes' however, they will be decoded as bytes object instead. ZBINBYTESBzPush a Python bytes object. There are two arguments: the first is a 4-byte little-endian unsigned int giving the number of bytes, and the second is that many bytes, which are taken literally as the bytes content. ZSHORT_BINBYTESCzPush a Python bytes object. There are two arguments: the first is a 1-byte unsigned int giving the number of bytes, and the second is that many bytes, which are taken literally as the string content. Z BINBYTES8ŽzPush a Python bytes object. There are two arguments: the first is an 8-byte unsigned int giving the number of bytes in the string, and the second is that many bytes, which are taken literally as the string content. ZNONENzPush None on the stack.ZNEWTRUEˆzPush True onto the stack.ZNEWFALSE‰zPush False onto the stack.UNICODEVzPush a Python Unicode string object. The argument is a raw-unicode-escape encoding of a Unicode string, and so may contain embedded escape sequences. The argument extends until the next newline character. ZSHORT_BINUNICODEŒaPush a Python Unicode string object. There are two arguments: the first is a 1-byte little-endian signed int giving the number of bytes in the string. The second is that many bytes, and is the UTF-8 encoding of the Unicode string. Z BINUNICODEXaPush a Python Unicode string object. There are two arguments: the first is a 4-byte little-endian unsigned int giving the number of bytes in the string. The second is that many bytes, and is the UTF-8 encoding of the Unicode string. Z BINUNICODE8aPush a Python Unicode string object. There are two arguments: the first is an 8-byte little-endian signed int giving the number of bytes in the string. The second is that many bytes, and is the UTF-8 encoding of the Unicode string. ZFLOATFaNewline-terminated decimal float literal. The argument is repr(a_float), and in general requires 17 significant digits for roundtrip conversion to be an identity (this is so for IEEE-754 double precision values, which is what Python float maps to on most boxes). In general, FLOAT cannot be used to transport infinities, NaNs, or minus zero across boxes (or even on a single box, if the platform C library can't read the strings it produces for such things -- Windows is like that), but may do less damage than BINFLOAT on boxes with greater precision or dynamic range than IEEE-754 double. ZBINFLOATGaFloat stored in binary form, with 8 bytes of data. This generally requires less than half the space of FLOAT encoding. In general, BINFLOAT cannot be used to transport infinities, NaNs, or minus zero, raises an exception if the exponent exceeds the range of an IEEE-754 double, and retains no more than 53 bits of precision (if there are more than that, "add a half and chop" rounding is used to cut it back to 53 significant bits). Z EMPTY_LIST]zPush an empty list.ZAPPENDazAppend an object to a list. Stack before: ... pylist anyobject Stack after: ... pylist+[anyobject] although pylist is really extended in-place. ZAPPENDSezExtend a list by a slice of stack objects. Stack before: ... pylist markobject stackslice Stack after: ... pylist+stackslice although pylist is really extended in-place. ZLISTlasBuild a list out of the topmost stack slice, after markobject. All the stack entries following the topmost markobject are placed into a single Python list, which single list object replaces all of the stack from the topmost markobject onward. For example, Stack before: ... markobject 1 2 3 'abc' Stack after: ... [1, 2, 3, 'abc'] Z EMPTY_TUPLE)zPush an empty tuple.ZTUPLEtavBuild a tuple out of the topmost stack slice, after markobject. All the stack entries following the topmost markobject are placed into a single Python tuple, which single tuple object replaces all of the stack from the topmost markobject onward. For example, Stack before: ... markobject 1 2 3 'abc' Stack after: ... (1, 2, 3, 'abc') ZTUPLE1…zBuild a one-tuple out of the topmost item on the stack. This code pops one value off the stack and pushes a tuple of length 1 whose one item is that value back onto it. In other words: stack[-1] = tuple(stack[-1:]) ZTUPLE2†aBuild a two-tuple out of the top two items on the stack. This code pops two values off the stack and pushes a tuple of length 2 whose items are those values back onto it. In other words: stack[-2:] = [tuple(stack[-2:])] ZTUPLE3‡aBuild a three-tuple out of the top three items on the stack. This code pops three values off the stack and pushes a tuple of length 3 whose items are those values back onto it. In other words: stack[-3:] = [tuple(stack[-3:])] Z EMPTY_DICT}zPush an empty dict.ZDICTdaBuild a dict out of the topmost stack slice, after markobject. All the stack entries following the topmost markobject are placed into a single Python dict, which single dict object replaces all of the stack from the topmost markobject onward. The stack slice alternates key, value, key, value, .... For example, Stack before: ... markobject 1 2 3 'abc' Stack after: ... {1: 2, 3: 'abc'} ZSETITEMrSzAdd a key+value pair to an existing dict. Stack before: ... pydict key value Stack after: ... pydict where pydict has been modified via pydict[key] = value. ZSETITEMSua\Add an arbitrary number of key+value pairs to an existing dict. The slice of the stack following the topmost markobject is taken as an alternating sequence of keys and values, added to the dict immediately under the topmost markobject. Everything at and after the topmost markobject is popped, leaving the mutated dict at the top of the stack. Stack before: ... pydict markobject key_1 value_1 ... key_n value_n Stack after: ... pydict where pydict has been modified via pydict[key_i] = value_i for i in 1, 2, ..., n, and in that order. Z EMPTY_SETzPush an empty set.ZADDITEMSa$Add an arbitrary number of items to an existing set. The slice of the stack following the topmost markobject is taken as a sequence of items, added to the set immediately under the topmost markobject. Everything at and after the topmost markobject is popped, leaving the mutated set at the top of the stack. Stack before: ... pyset markobject item_1 ... item_n Stack after: ... pyset where pyset has been modified via pyset.add(item_i) = item_i for i in 1, 2, ..., n, and in that order. Z FROZENSET‘azBuild a frozenset out of the topmost slice, after markobject. All the stack entries following the topmost markobject are placed into a single Python frozenset, which single frozenset object replaces all of the stack from the topmost markobject onward. For example, Stack before: ... markobject 1 2 3 Stack after: ... frozenset({1, 2, 3}) POP0z. ZBUILDbaFinish building an object, via __setstate__ or dict update. Stack before: ... anyobject argument Stack after: ... anyobject where anyobject may have been mutated, as follows: If the object has a __setstate__ method, anyobject.__setstate__(argument) is called. Else the argument must be a dict, the object must have a __dict__, and the object is updated via anyobject.__dict__.update(argument) ZINSTiaqBuild a class instance. This is the protocol 0 version of protocol 1's OBJ opcode. INST is followed by two newline-terminated strings, giving a module and class name, just as for the GLOBAL opcode (and see GLOBAL for more details about that). self.find_class(module, name) is used to get a class object. In addition, all the objects on the stack following the topmost markobject are gathered into a tuple and popped (along with the topmost markobject), just as for the TUPLE opcode. Now it gets complicated. If all of these are true: + The argtuple is empty (markobject was at the top of the stack at the start). + The class object does not have a __getinitargs__ attribute. then we want to create an old-style class instance without invoking its __init__() method (pickle has waffled on this over the years; not calling __init__() is current wisdom). In this case, an instance of an old-style dummy class is created, and then we try to rebind its __class__ attribute to the desired class object. If this succeeds, the new instance object is pushed on the stack, and we're done. Else (the argtuple is not empty, it's not an old-style class object, or the class object does have a __getinitargs__ attribute), the code first insists that the class object have a __safe_for_unpickling__ attribute. Unlike as for the __safe_for_unpickling__ check in REDUCE, it doesn't matter whether this attribute has a true or false value, it only matters whether it exists (XXX this is a bug). If __safe_for_unpickling__ doesn't exist, UnpicklingError is raised. Else (the class object does have a __safe_for_unpickling__ attr), the class object obtained from INST's arguments is applied to the argtuple obtained from the stack, and the resulting instance object is pushed on the stack. NOTE: checks for __safe_for_unpickling__ went away in Python 2.3. NOTE: the distinction between old-style and new-style classes does not make sense in Python 3. ZOBJoaBuild a class instance. This is the protocol 1 version of protocol 0's INST opcode, and is very much like it. The major difference is that the class object is taken off the stack, allowing it to be retrieved from the memo repeatedly if several instances of the same class are created. This can be much more efficient (in both time and space) than repeatedly embedding the module and class names in INST opcodes. Unlike INST, OBJ takes no arguments from the opcode stream. Instead the class object is taken off the stack, immediately above the topmost markobject: Stack before: ... markobject classobject stackslice Stack after: ... new_instance_object As for INST, the remainder of the stack above the markobject is gathered into an argument tuple, and then the logic seems identical, except that no __safe_for_unpickling__ check is done (XXX this is a bug). See INST for the gory details. NOTE: In Python 2.3, INST and OBJ are identical except for how they get the class object. That was always the intent; the implementations had diverged for accidental reasons. ZNEWOBJaLBuild an object instance. The stack before should be thought of as containing a class object followed by an argument tuple (the tuple being the stack top). Call these cls and args. They are popped off the stack, and the value returned by cls.__new__(cls, *args) is pushed back onto the stack. Z NEWOBJ_EX’auBuild an object instance. The stack before should be thought of as containing a class object followed by an argument tuple and by a keyword argument dict (the dict being the stack top). Call these cls and args. They are popped off the stack, and the value returned by cls.__new__(cls, *args, *kwargs) is pushed back onto the stack. PROTO€zProtocol version indicator. For protocol 2 and above, a pickle must start with this opcode. The argument is the protocol version, an int in range(2, 256). ZSTOP.zStop the unpickling machine. Every pickle ends with this opcode. The object at the top of the stack is popped, and that's the result of unpickling. The stack should be empty then. FRAME•zIndicate the beginning of a new frame. The unpickler may use this opcode to safely prefetch data from its underlying stream. ZPERSIDPaPush an object identified by a persistent ID. The pickle module doesn't define what a persistent ID means. PERSID's argument is a newline-terminated str-style (no embedded escapes, no bracketing quote characters) string, which *is* "the persistent ID". The unpickler passes this string to self.persistent_load(). Whatever object that returns is pushed on the stack. There is no implementation of persistent_load() in Python's unpickler: it must be supplied by an unpickler subclass. Z BINPERSIDQaXPush an object identified by a persistent ID. Like PERSID, except the persistent ID is popped off the stack (instead of being a string embedded in the opcode bytestream). The persistent ID is passed to self.persistent_load(), and whatever object that returns is pushed on the stack. See PERSID for more detail. z%repeated name %r at indices %d and %dz%repeated code %r at indices %d and %dFcCstj}xtjD]}tjd|s2|rtd|qtt|}t|t  sTt |dkrj|rtd||fq|j d}||kr|rtd||f||}|j |krt d|||j f||=qt d||fqW|rd g}x(|jD]\}}|jd |j |fqWt d j|dS) Nz[A-Z][A-Z0-9_]+$z0skipping %r: it doesn't look like an opcode namerz5skipping %r: value %r doesn't look like a pickle codezlatin-1z+checking name %r w/ code %r for consistencyzBfor pickle code %r, pickle.py uses name %r but we're using name %rzPpickle.py appears to have a pickle opcode with name %r and code %r, but we don'tz=we appear to have pickle opcodes that pickle.py doesn't have:z name %r with code %r )code2opcopypickle__all__rematchprintgetattrrerirr3r ritemsappendjoin)verboserr Z picklecodermsgrrrrrassure_pickle_consistencys>         rccst|trtj|}t|dr&|j}ndd}x|}|jd}tj|j d}|dkr|dkrjt dnt d|dkrzd n||f|j dkrd}n |j j |}|r||||fVn |||fV|d kr0Pq0WdS) NtellcSsdS)Nrrrrrsz_genops..rzlatin-1z#pickle exhausted before seeing STOPz!at position %s, opcode %r unknownz .) re bytes_typesioBytesIOhasattrrrrgetr3rrsr )r yield_end_posZgetposposrropcodersrrr_genopss.         rcCst|S)axGenerate all the opcodes in a pickle. 'pickle' is a file-like object, or string, containing the pickle. Each opcode in the pickle is generated, from the current pickle position, stopping after a STOP opcode is delivered. A triple is generated for each opcode: opcode, arg, pos opcode is an OpcodeInfo record, describing the current opcode. If the opcode has an argument embedded in the pickle, arg is its decoded value, as a Python object. If the opcode doesn't have an argument, arg is None. If the pickle has a tell() method, pos was the value of pickle.tell() before reading the current opcode. If the pickle is a bytes object, it's wrapped in a BytesIO object, and the latter's tell() result is used. Else (the pickle doesn't have a tell(), and it's not obvious how to query its current position) pos is None. )r)rrrrrscCsd}d}t}i}g}d}d}xt|ddD]\}} } } d|jkr\|j| |j|| fq,|jdkrt|} |j| |j|| fq,d|jkrq,d|jkr|j|kr|j}d || <|j|| fq,|jd kr| |kr| }| dkr|| | }n|j| | fq,|j| | fq,W~tj} | j |t j | |}|d krJ|j j d} x|D]x\}} ||kr| |krtqT|j| }| || <| d 7} n&||kr|j|| }n ||| }|j j|j |qTW|j j| jS) z7Optimize a pickle string by removing unused PUT opcodesrrrrT)rrrNrrr)rmrr addrrrvrrwriterZ_PicklerZframerZ start_framingputrZ commit_frameZ end_framinggetvalue)rrrZoldidsZnewidsopcodesrvZ protoheaderrrsrZend_posidxoutZpickleroprrrrrsd                    cCsg}|dkri}d}g}d|}d} |} xt|D]\} } } | dk rZtd| d|ddt| jdd |t|| jf}t|| j}| j}| j }t|}d}t |ks| jdko|o|d!t krD|r<|j }|dkrd}nd |}x|d"t k r|j qW|j y|j t }Wnt k r8d }YnXnd } }| jd#kr| jdkrnt|}d|}n| }||krd| } n,|sd} n |d$t krd} n |d%||<n*| jd&kr| |kr|| g}nd| } | dk s|r0|ddt| j7}| dk r|dt| 7}|r0|d|7}|rz|d| t|7}t|} | dkr`|} |d| jjddd 7}t||d| rt | t||krt d|t|f|r|| d=t |kr|j| |j|q4Wtd||d|r t d|dS)'aKProduce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which the disassembly is printed. It defaults to sys.stdout. Optional arg 'memo' is a Python dict, used as the pickle's memo. It may be mutated by dis(), if the pickle contains PUT or BINPUT opcodes. Passing the same memo object to another dis() call then allows disassembly to proceed across multiple pickles that were all created by the same pickler with the same memo. Ordinarily you don't need to worry about this. Optional arg 'indentlevel' is the number of blanks by which to indent a new MARK level. It defaults to 4. Optional arg 'annotate' if nonzero instructs dis() to add short description of the opcode on each line of disassembled output. The value given to 'annotate' must be an integer and is used as a hint for the column where annotation should start. The default value is 0, meaning no annotations. In addition to printing the disassembly, some sanity checks are made: + All embedded opcode arguments "make sense". + Explicit and implicit pop operations have enough items on the stack. + When an opcode implicitly refers to a markobject, a markobject is actually on the stack. + A memo entry isn't referenced before it's defined. + The markobject isn't stored in the memo. + A memo entry isn't redefined. Nr z%5d:)endfilez %-4s %s%srz(MARK at unknown opcode offset)z (MARK at %d)rzno MARK exists on stackrrrrz(as %d)zmemo key %r already definedz'stack is empty -- can't store into memoz"can't store markobject in the memorrrz&memo key %r has never been stored into 2r)rz3tries to pop %d items from stack with only %d itemsz highest protocol among opcodes =zstack not empty after STOP: %rr-r-r-r-)rrrrr-r-)rrr)rrreprrrrr maxrvrtru markobjectpopindexrrsplitrextend)rrmemo indentlevelannotatestackZmaxprotoZ markstackZ indentchunkZerrormsgZannocolrrsrlineZbeforeafterZnumtopopZmarkmsgZmarkposZmemo_idxrrrr% s-                    c@seZdZddZdS)_ExamplecCs ||_dS)N)value)rrrrrr sz_Example.__init__N)rrrrrrrrr sra >>> import pickle >>> x = [1, 2, (3, 4), {b'abc': "def"}] >>> pkl0 = pickle.dumps(x, 0) >>> dis(pkl0) 0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 5: L LONG 1 9: a APPEND 10: L LONG 2 14: a APPEND 15: ( MARK 16: L LONG 3 20: L LONG 4 24: t TUPLE (MARK at 15) 25: p PUT 1 28: a APPEND 29: ( MARK 30: d DICT (MARK at 29) 31: p PUT 2 34: c GLOBAL '_codecs encode' 50: p PUT 3 53: ( MARK 54: V UNICODE 'abc' 59: p PUT 4 62: V UNICODE 'latin1' 70: p PUT 5 73: t TUPLE (MARK at 53) 74: p PUT 6 77: R REDUCE 78: p PUT 7 81: V UNICODE 'def' 86: p PUT 8 89: s SETITEM 90: a APPEND 91: . STOP highest protocol among opcodes = 0 Try again with a "binary" pickle. >>> pkl1 = pickle.dumps(x, 1) >>> dis(pkl1) 0: ] EMPTY_LIST 1: q BINPUT 0 3: ( MARK 4: K BININT1 1 6: K BININT1 2 8: ( MARK 9: K BININT1 3 11: K BININT1 4 13: t TUPLE (MARK at 8) 14: q BINPUT 1 16: } EMPTY_DICT 17: q BINPUT 2 19: c GLOBAL '_codecs encode' 35: q BINPUT 3 37: ( MARK 38: X BINUNICODE 'abc' 46: q BINPUT 4 48: X BINUNICODE 'latin1' 59: q BINPUT 5 61: t TUPLE (MARK at 37) 62: q BINPUT 6 64: R REDUCE 65: q BINPUT 7 67: X BINUNICODE 'def' 75: q BINPUT 8 77: s SETITEM 78: e APPENDS (MARK at 3) 79: . STOP highest protocol among opcodes = 1 Exercise the INST/OBJ/BUILD family. >>> import pickletools >>> dis(pickle.dumps(pickletools.dis, 0)) 0: c GLOBAL 'pickletools dis' 17: p PUT 0 20: . STOP highest protocol among opcodes = 0 >>> from pickletools import _Example >>> x = [_Example(42)] * 2 >>> dis(pickle.dumps(x, 0)) 0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 5: c GLOBAL 'copy_reg _reconstructor' 30: p PUT 1 33: ( MARK 34: c GLOBAL 'pickletools _Example' 56: p PUT 2 59: c GLOBAL '__builtin__ object' 79: p PUT 3 82: N NONE 83: t TUPLE (MARK at 33) 84: p PUT 4 87: R REDUCE 88: p PUT 5 91: ( MARK 92: d DICT (MARK at 91) 93: p PUT 6 96: V UNICODE 'value' 103: p PUT 7 106: L LONG 42 111: s SETITEM 112: b BUILD 113: a APPEND 114: g GET 5 117: a APPEND 118: . STOP highest protocol among opcodes = 0 >>> dis(pickle.dumps(x, 1)) 0: ] EMPTY_LIST 1: q BINPUT 0 3: ( MARK 4: c GLOBAL 'copy_reg _reconstructor' 29: q BINPUT 1 31: ( MARK 32: c GLOBAL 'pickletools _Example' 54: q BINPUT 2 56: c GLOBAL '__builtin__ object' 76: q BINPUT 3 78: N NONE 79: t TUPLE (MARK at 31) 80: q BINPUT 4 82: R REDUCE 83: q BINPUT 5 85: } EMPTY_DICT 86: q BINPUT 6 88: X BINUNICODE 'value' 98: q BINPUT 7 100: K BININT1 42 102: s SETITEM 103: b BUILD 104: h BINGET 5 106: e APPENDS (MARK at 3) 107: . STOP highest protocol among opcodes = 1 Try "the canonical" recursive-object test. >>> L = [] >>> T = L, >>> L.append(T) >>> L[0] is T True >>> T[0] is L True >>> L[0][0] is L True >>> T[0][0] is T True >>> dis(pickle.dumps(L, 0)) 0: ( MARK 1: l LIST (MARK at 0) 2: p PUT 0 5: ( MARK 6: g GET 0 9: t TUPLE (MARK at 5) 10: p PUT 1 13: a APPEND 14: . STOP highest protocol among opcodes = 0 >>> dis(pickle.dumps(L, 1)) 0: ] EMPTY_LIST 1: q BINPUT 0 3: ( MARK 4: h BINGET 0 6: t TUPLE (MARK at 3) 7: q BINPUT 1 9: a APPEND 10: . STOP highest protocol among opcodes = 1 Note that, in the protocol 0 pickle of the recursive tuple, the disassembler has to emulate the stack in order to realize that the POP opcode at 16 gets rid of the MARK at 0. >>> dis(pickle.dumps(T, 0)) 0: ( MARK 1: ( MARK 2: l LIST (MARK at 1) 3: p PUT 0 6: ( MARK 7: g GET 0 10: t TUPLE (MARK at 6) 11: p PUT 1 14: a APPEND 15: 0 POP 16: 0 POP (MARK at 0) 17: g GET 1 20: . STOP highest protocol among opcodes = 0 >>> dis(pickle.dumps(T, 1)) 0: ( MARK 1: ] EMPTY_LIST 2: q BINPUT 0 4: ( MARK 5: h BINGET 0 7: t TUPLE (MARK at 4) 8: q BINPUT 1 10: a APPEND 11: 1 POP_MARK (MARK at 0) 12: h BINGET 1 14: . STOP highest protocol among opcodes = 1 Try protocol 2. >>> dis(pickle.dumps(L, 2)) 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 5: h BINGET 0 7: \x85 TUPLE1 8: q BINPUT 1 10: a APPEND 11: . STOP highest protocol among opcodes = 2 >>> dis(pickle.dumps(T, 2)) 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 5: h BINGET 0 7: \x85 TUPLE1 8: q BINPUT 1 10: a APPEND 11: 0 POP 12: h BINGET 1 14: . STOP highest protocol among opcodes = 2 Try protocol 3 with annotations: >>> dis(pickle.dumps(T, 3), annotate=1) 0: \x80 PROTO 3 Protocol version indicator. 2: ] EMPTY_LIST Push an empty list. 3: q BINPUT 0 Store the stack top into the memo. The stack is not popped. 5: h BINGET 0 Read an object from the memo and push it on the stack. 7: \x85 TUPLE1 Build a one-tuple out of the topmost item on the stack. 8: q BINPUT 1 Store the stack top into the memo. The stack is not popped. 10: a APPEND Append an object to a list. 11: 0 POP Discard the top stack item, shrinking the stack by one item. 12: h BINGET 1 Read an object from the memo and push it on the stack. 14: . STOP Stop the unpickling machine. highest protocol among opcodes = 2 a= >>> import pickle >>> import io >>> f = io.BytesIO() >>> p = pickle.Pickler(f, 2) >>> x = [1, 2, 3] >>> p.dump(x) >>> p.dump(x) >>> f.seek(0) 0 >>> memo = {} >>> dis(f, memo=memo) 0: \x80 PROTO 2 2: ] EMPTY_LIST 3: q BINPUT 0 5: ( MARK 6: K BININT1 1 8: K BININT1 2 10: K BININT1 3 12: e APPENDS (MARK at 5) 13: . STOP highest protocol among opcodes = 2 >>> dis(f, memo=memo) 14: \x80 PROTO 2 16: h BINGET 0 18: . STOP highest protocol among opcodes = 2 )Zdisassembler_testZdisassembler_memo_testcCsddl}|jS)Nr)doctestZtestmod)rrrr_test sr__main__z$disassemble one or more pickle files)Z description pickle_filebr*zthe pickle file)typenargshelpz-oz--outputwz+the file where the output should be written)defaultrrz-mz--memo store_truez#preserve memo between disassemblies)actionrz-lz --indentlevelz8the number of blanks by which to indent a new MARK levelz-az --annotatez2annotate each line with a short opcode descriptionz-pz --preamblez==> {name} <==zMif more than one pickle file is specified, print this before each disassembly)rrz-tz--testzrun self-test suitez-vz)run verbosely; only affects self-test run)r rr-)TT)F)F)NNrr)__doc__r1rrrrBrrZ UP_TO_NEWLINEZTAKEN_FROM_ARGUMENT1ZTAKEN_FROM_ARGUMENT4ZTAKEN_FROM_ARGUMENT4UZTAKEN_FROM_ARGUMENT8Uobjectr Zstructrrrrr r!r"r#r$r%r'r(r6r7r8r9r:r;r<r=r>r?r@rArDrErFrGrIrJrLrMrNrOrPrQrTrVrWrXrZr[r\r]r^r_r`rarbrcrRZpyintZpylongrhZpyinteger_or_boolZpyboolrYZpyfloatrirHZpybytes_or_strZpystringZpybytesZ pyunicoderZpynonerfZpytuplerkZpylistrlZpydictrmZpysetZ pyfrozensetZ anyobjectrrprqrxrZname2iZcode2i enumeraterrr rrrrrrrrrrZ _dis_testZ _memo_testZ__test__rrargparseArgumentParserparser add_argumentZFileTypestdout parse_argsargsZtestrrZ print_helproutputrrrZpreambleformatrrrrr s $   /        ;           +      &  >                   _osx_support.cpython-36.opt-1.pyc000064400000022754151027002730012704 0ustar003 \J @sdZddlZddlZddlZddddgZd1Zd2ZdZd3ddZddZ ddZ da ddZ ddZ dd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-dZd.dZd/dZd0dZdS)4zShared OS X support functions.Ncompiler_fixupcustomize_config_varscustomize_compilerget_platform_osxCFLAGSLDFLAGSCPPFLAGS BASECFLAGS BLDSHAREDLDSHAREDCCCXX PY_CFLAGS PY_LDFLAGS PY_CPPFLAGSPY_CORE_CFLAGSPY_CORE_LDFLAGSZ_OSX_SUPPORT_INITIAL_cCs|dkrtjd}|jtj}tjj|\}}tjdkrH|dkrH|d}tjj|sx*|D]"}tjj ||}tjj|rZ|SqZWdS|SdS)zTries to find 'executable' in the directories listed in 'path'. A string listing directories separated by 'os.pathsep'; defaults to os.environ['PATH']. Returns the complete filename or None if not found. NPATHZwin32z.exe) osenvironsplitpathseppathsplitextsysplatformisfilejoin) executablerpathsbaseZextpfr#$/usr/lib64/python3.6/_osx_support.py_find_executables     r%cCsddl}yddl}|j}Wn(tk rDtdtjfd}YnX|j|0}d||jf}tj |s||j j dj SdSQRXdS)z0Output from successful command execution or NonerNz/tmp/_osx_support.%szw+bz%s 2>/dev/null >'%s'zutf-8) contextlibtempfileZNamedTemporaryFile ImportErroropenrgetpidclosingnamesystemreaddecodestrip)Z commandstringr&r'fpcmdr#r#r$ _read_output7s  r3cCst|ptd|fpdS)z0Find a build tool on current path or using xcrunz/usr/bin/xcrun -find %s)r%r3)Ztoolnamer#r#r$_find_build_toolJsr5cCsxtdkrtday td}Wntk r,YnHXztjd|j}Wd|jX|dk rtdj|jdj dddatS)z*Return the OS X system version as a stringNr4z0/System/Library/CoreServices/SystemVersion.plistz=ProductUserVisibleVersion\s*(.*?).) _SYSTEM_VERSIONr)OSErrorresearchr.closergroupr)r"mr#r#r$_get_system_versionSs   r@cCs&x t|D]}|jtr ||=q WdS)z-Remove original unmodified values for testingN)list startswith_INITPRE) _config_varskr#r#r$_remove_original_valuesqs rFcCs8|j|d}||kr,t||kr,||t|<|||<dS)z@Save modified and original unmodified value of configuration varr4N)getrC)rDcvZnewvalueZoldvaluer#r#r$_save_modified_valuexs  rIc CsTt}|r@ytdd|jdD}Wntk r>d}YnX|rPt|dkSdS) z=Returns True if universal builds are supported on this systemcss|]}t|VqdS)N)int).0ir#r#r$ sz-_supports_universal_builds..r6r4 F)rNrO)r@tupler ValueErrorbool)Z osx_versionr#r#r$_supports_universal_buildss rScCsdtjkr|S|djd}}t|s4td}n/dev/nullrUz'"'"'z-arch\s+ppc\w*\srV) rrr;r<r-rXr^r_rI)rDZstatusrHr]r#r#r$_remove_unsupported_archss  rbcCshdtjkrdtjd}xNtD]F}||krd||kr||}tjdd|}|d|}t|||qW|S)z2Allow override of all archs with ARCHFLAGS env var ARCHFLAGSz-archz -arch\s+\w+\srV)rrr^r;r_rI)rDZarchrHr]r#r#r$_override_all_archss    rdcCs||jdd}tjd|}|dk rx|jd}tjj|sxx@tD]8}||kr<|tjkr<||}tj dd|}t |||qrrexistsr^rr_rI)rDcflagsr?ZsdkrHr]r#r#r$_check_for_unavailable_sdks     rgc CsXd}}t|}ts d}}nd|k}d|k}|s>dtjkrxx8y|jd}|||d=Wq@tk rrPYq@Xq@Wdtjkr| r|tjdj}|rx8y|jd}|||d=Wqtk rPYqXqWd}d|kr|jd}||d}n d|kr|jd}||d}|rTtjj| rTd d l m }|j d ||j d |S) ae This function will strip '-isysroot PATH' and '-arch ARCH' from the compile flags if the user has specified one them in extra_compile_flags. This is needed because '-arch ARCH' adds another architecture to the build, without a way to remove an architecture. Furthermore GCC will barf if multiple '-isysroot' arguments are present. FTz-archz -isysrootrcr8Nr7r)logz4Compiling with an SDK that doesn't seem to exist: %sz$Please check your Xcode installation) rArSrrindexrQrrisdirZ distutilsrhwarn)Z compiler_soZcc_argsZ stripArchZ stripSysrootriZsysrootidxrhr#r#r$r0sF            cCs"tst|t|t||S)aCustomize Python build configuration variables. Called internally from sysconfig with a mutable mapping containing name/value pairs parsed from the configured makefile used to build this interpreter. Returns the mapping updated as needed to reflect the environment in which the interpreter is running; in the case of a Python from a binary installer, the installed environment may be very different from the build environment, i.e. different OS levels, different built tools, different available CPU architectures. This customization is performed whenever distutils.sysconfig.get_config_vars() is first called. It may be used in environments where no compilers are present, i.e. when installing pure Python dists. Customization of compiler paths and detection of unavailable archs is deferred until the first extension module build is requested (in distutils.sysconfig.customize_compiler). Currently called from distutils.sysconfig )rSrardrg)rDr#r#r$rps cCst|t|t||S)zCustomize compiler path and configuration variables. This customization is performed when the first extension module build is requested in distutils.sysconfig.customize_compiler). )r\rbrd)rDr#r#r$rs c Cs||jdd}tp|}|p|}|rr|}d}|jtd|jdd}|ry$tdd|jddd D}Wqtk rd}YqXnd}|dkod |jkr6d }tjd|}tt t |}t |dkr|d}n\|dkrd }nN|d krd}n>|d!krd}n.|d"krd}n|d#kr&d}ntd|fn<|dkrRt j d$krrd}n |d%krrt j d&krnd}nd}|||fS)'z Filter values for get_platform()MACOSX_DEPLOYMENT_TARGETr4Zmacosxrcss|]}t|VqdS)N)rJ)rKrLr#r#r$rMsz#get_platform_osx..r6rr8rNrOz-archZfatz -arch\s+(\S+)r7i386ppcx86_64ZintelZfat3ppc64Zfat64Z universalz%Don't know machine value for archs=%r PowerPCPower_Macintosh)rNr)rNr)rNrO)rnro)rnrp)rnrorp)rqrp)rnrorqrpl)rsrtl)rGr@rCrPrrQr0r;findallsortedsetlenrmaxsize)rDosnamereleasemachineZmacverZ macreleaserfZarchsr#r#r$rsP   $            ) rrrr r r r r rrrrr)r r r r )N)__doc__rr;r__all__r^rZrCr%r3r5r9r@rFrIrSr\rarbrdrgrrrrr#r#r#r$s< >(@)bdb.cpython-36.opt-1.pyc000064400000041213151027002730010656 0ustar003 \\@sdZddlZddlZddlZddlmZmZmZdddgZeeBeBZ Gddde Z GdddZ d d Z Gd ddZd d ZddZGddde ZddZddZddZdS)zDebugger basicsN) CO_GENERATOR CO_COROUTINECO_ASYNC_GENERATORBdbQuitBdb Breakpointc@seZdZdZdS)rz Exception to give up completely.N)__name__ __module__ __qualname____doc__r r /usr/lib64/python3.6/bdb.pyr sc@speZdZdZdZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd[d&d'Zd\d(d)Zd*d+Zd,d-Zd.d/Zd]d0d1Zd2d3Zd4d5Zd^d7d8Zd9d:Zd;d<Zd=d>Z d?d@Z!dAdBZ"dCdDZ#dEdFZ$dGdHZ%dIdJZ&dKdLZ'dMdNZ(d_dPdQZ)d`dRdSZ*dadTdUZ+dVdWZ,dXdYZ-dS)brzGeneric Python debugger base class. This class takes care of details of the trace facility; a derived class should implement user interaction. The standard debugger class (pdb.Pdb) is an example. NcCs(|r t|nd|_i|_i|_d|_dS)N)setskipbreaksfncacheframe_returning)selfrr r r __init__sz Bdb.__init__cCsR|d|dddkr|S|jj|}|sNtjj|}tjj|}||j|<|S)N<>)rgetospathabspathnormcase)rfilenamecanonicr r r rs    z Bdb.canoniccCs&ddl}|jd|_|jdddS)Nr) linecache checkcachebotframe _set_stopinfo)rr r r r reset)sz Bdb.resetcCs|jr dS|dkr|j|S|dkr0|j||S|dkrD|j||S|dkrX|j||S|dkrf|jS|dkrt|jS|dkr|jStdt||jS) NlineZcallreturnZ exceptionZc_callZ c_exceptionZc_returnz*bdb.Bdb.dispatch: unknown debugging event:)quitting dispatch_line dispatch_calldispatch_returndispatch_exceptiontrace_dispatchprintrepr)rframeZeventargr r r r,/s$    zBdb.trace_dispatchcCs.|j|s|j|r(|j||jr(t|jS)N) stop_here break_here user_liner'rr,)rr/r r r r(Cs  zBdb.dispatch_linecCsd|jdkr|j|_|jS|j|p*|j|s0dS|jrH|jjt@rH|jS|j |||j r^t |jS)N) r"f_backr,r1break_anywhere stopframef_codeco_flagsGENERATOR_AND_COROUTINE_FLAGS user_callr'r)rr/r0r r r r)Is  zBdb.dispatch_callc Cs||j|s||jkrv|jr,|jjt@r,|jSz||_|j||Wdd|_X|j rVt |j|krv|j dkrv|j dd|jS)Nrr) r1 returnframer6r7r8r9r,r user_returnr'r stoplinenor#)rr/r0r r r r*Ys zBdb.dispatch_returncCs|j|rF|jjt@o,|dtko,|ddks|j|||jrtnD|jr||jk r|jjjt@r|dtt fkr|j|||jrt|j S)Nr) r1r7r8r9 StopIterationuser_exceptionr'rr6 GeneratorExitr,)rr/r0r r r r+is    zBdb.dispatch_exceptioncCs$x|jD]}tj||rdSqWdS)NTF)rfnmatch)rZ module_namepatternr r r is_skipped_modules  zBdb.is_skipped_modulecCsN|jr|j|jjdrdS||jkr@|jdkr4dS|j|jkS|jsJdSdS)NrFrTr)rrD f_globalsrr6r=f_lineno)rr/r r r r1s   z Bdb.stop_herecCs|j|jj}||jkrdS|j}||j|krJ|jj}||j|krJdSt|||\}}|r|j|_|r|j r|j t |jdSdSdS)NFT) rr7 co_filenamerrFco_firstlineno effectivenumberZ currentbp temporarydo_clearstr)rr/rlinenobpflagr r r r2s  zBdb.break_herecCs tddS)Nz)subclass of bdb must implement do_clear())NotImplementedError)rr0r r r rLsz Bdb.do_clearcCs|j|jj|jkS)N)rr7rGr)rr/r r r r5szBdb.break_anywherecCsdS)znThis method is called when there is the remote possibility that we ever need to stop in this function.Nr )rr/Z argument_listr r r r:sz Bdb.user_callcCsdS)z9This method is called when we stop or break at this line.Nr )rr/r r r r3sz Bdb.user_linecCsdS)z5This method is called when a return trap is set here.Nr )rr/Z return_valuer r r r<szBdb.user_returncCsdS)zmThis method is called if an exception occurs, but only if we are to stop at or just below this level.Nr )rr/exc_infor r r r@szBdb.user_exceptionrcCs||_||_d|_||_dS)NF)r6r;r'r=)rr6r;r=r r r r#szBdb._set_stopinfocCs$|dkr|jd}|j|||dS)zxStop when the line with the line no greater than the current one is reached or when returning from current frameNr)rFr#)rr/rNr r r set_untils z Bdb.set_untilcCs2|jr"|jj}|r"|j r"|j|_|jdddS)zStop after one line of code.N)rr4f_tracer,r#)rZ caller_framer r r set_steps  z Bdb.set_stepcCs|j|ddS)z2Stop on the next line in or below the given frame.N)r#)rr/r r r set_nextsz Bdb.set_nextcCs.|jjt@r|j|ddn|j|j|dS)z)Stop when returning from the given frame.Nrr)r7r8r9r#r4)rr/r r r set_returns zBdb.set_returncCsP|dkrtjj}|jx|r6|j|_||_|j}qW|jtj|jdS)zpStart debugging from `frame`. If frame is not specified, debugging starts from caller's frame. N) sys _getframer4r$r,rTr"rUsettrace)rr/r r r set_traces  z Bdb.set_tracecCsL|j|jdd|jsHtjdtjj}x|rF||jk rF|`|j}q,WdS)Nrr)r#r"rrXrZrYr4rT)rr/r r r set_continues  zBdb.set_continuecCs"|j|_d|_d|_tjddS)NT)r"r6r;r'rXrZ)rr r r set_quit sz Bdb.set_quitFc Csb|j|}ddl}|j||}|s.d||fS|jj|g}||krN|j|t|||||} dS)NrzLine %s:%d does not exist)rr getliner setdefaultappendr) rrrNrKcondfuncnamer r%listrOr r r set_breaks    z Bdb.set_breakcCs4||ftjkr|j|j||j|s0|j|=dS)N)rbplistrremove)rrrNr r r _prune_breaks$s zBdb._prune_breakscCsn|j|}||jkrd|S||j|kr6d||fSx&tj||fddD] }|jqNW|j||dS)NzThere are no breakpoints in %szThere is no breakpoint at %s:%d)rrrredeleteMerg)rrrNrOr r r clear_break*s    zBdb.clear_breakcCsPy|j|}Wn$tk r2}zt|Sd}~XnX|j|j|j|jdS)N)get_bpbynumber ValueErrorrMrhrgfiler%)rr0rOerrr r r clear_bpbynumber6s zBdb.clear_bpbynumbercCs`|j|}||jkrd|Sx6|j|D](}tj||f}x|D] }|jq@Wq(W|j|=dS)NzThere are no breakpoints in %s)rrrrerh)rrr%ZblistrOr r r clear_all_file_breaks>s   zBdb.clear_all_file_breakscCs0|js dSxtjD]}|r|jqWi|_dS)NzThere are no breakpoints)rr bpbynumberrh)rrOr r r clear_all_breaksHs   zBdb.clear_all_breakscCs|s tdy t|}Wn tk r8td|YnXytj|}Wn tk rhtd|YnX|dkr~td||S)NzBreakpoint number expectedz Non-numeric breakpoint number %sz!Breakpoint number %d out of rangezBreakpoint %d already deleted)rkintrrp IndexError)rr0rJrOr r r rjPs  zBdb.get_bpbynumbercCs"|j|}||jko ||j|kS)N)rr)rrrNr r r get_break_s  z Bdb.get_breakcCs4|j|}||jkr0||j|kr0tj||fp2gS)N)rrrre)rrrNr r r get_breaksds  zBdb.get_breakscCs&|j|}||jkr|j|SgSdS)N)rr)rrr r r get_file_breaksjs   zBdb.get_file_breakscCs|jS)N)r)rr r r get_all_breaksqszBdb.get_all_breakscCsg}|r|j|kr|j}x.|dk rF|j||jf||jkr>P|j}qW|jtdt|d}x$|dk r|j|j|j f|j}qdW|dkrtdt|d}||fS)Nrr) tb_frametb_nextr`rFr"r4reversemaxlen tb_lineno)rftstackir r r get_stackws      z Bdb.get_stack: c Csddl}ddl}|\}}|j|jj}d||f}|jjrH||jj7}n|d7}d|jkrf|jd} nd} | r~||j| 7}n|d7}d|jkr|jd} |d7}||j| 7}|j|||j } | r||| j 7}|S)Nrz%s(%r)zZ__args__z()Z __return__z->) r reprlibrr7rGco_namef_localsr.r^rEstrip) rZ frame_linenoZlprefixr rr/rNrsargsrvr%r r r format_stack_entrys*     zBdb.format_stack_entrycCs|dkrddl}|j}|dkr"|}|jt|tr@t|dd}tj|jz*yt |||Wnt k rrYnXWdd|_ tjdXdS)NrzexecT) __main____dict__r$ isinstancerMcompilerXrZr,rrr')rcmdglobalslocalsrr r r runs    zBdb.runcCst|dkrddl}|j}|dkr"|}|jtj|jz&y t|||Stk rXYnXWdd|_tjdXdS)NrT) rrr$rXrZr,evalrr')rexprrrrr r r runevals   z Bdb.runevalcCs|j|||dS)N)r)rrrrr r r runctxsz Bdb.runctxcOsX|jtj|jd}z(y|||}Wntk r<YnXWdd|_tjdX|S)NT)r$rXrZr,rr')rfuncrkwdsresr r r runcalls   z Bdb.runcall)N)r)N)N)FNN)r)NN)NN).rr r r rrr$r,r(r)r*r+rDr1r2rLr5r:r3r<r@r#rSrUrVrWr[r\r]rdrgrirnrorqrjrtrurvrwrrrrrrr r r r rsX             cCstjdS)N)rr[r r r r r[sr[c@sZeZdZdZdZiZdgZdddZddZd d Z d d Z dd dZ ddZ ddZ dS)raBreakpoint class. Implements temporary breakpoints, ignore counts, disabling and (re)-enabling, and conditionals. Breakpoints are indexed by number through bpbynumber and by the file,line tuple using bplist. The former points to a single instance of class Breakpoint. The latter points to a list of such instances since there may be more than one breakpoint per line. rNFcCs||_d|_||_||_||_||_d|_d|_d|_t j |_ t j d7_ |j j |||f|jkr||j||fj |n|g|j||f<dS)NTrr)rbfunc_first_executable_linerlr%rKraenabledignorehitsrnextrJrpr`re)rrlr%rKrarbr r r rs zBreakpoint.__init__cCs>|j|jf}d|j|j<|j|j||j|s:|j|=dS)N)rlr%rprJrerf)rindexr r r rh s    zBreakpoint.deleteMecCs d|_dS)NT)r)rr r r enableszBreakpoint.enablecCs d|_dS)NF)r)rr r r disableszBreakpoint.disablecCs"|dkrtj}t|j|ddS)N)rl)rXstdoutr-bpformat)routr r r bpprintszBreakpoint.bpprintcCs|jr d}nd}|jr |d}n|d}d|j||j|jf}|jrT|d|jf7}|jrj|d|jf7}|jr|jdkrd }nd }|d |j|f7}|S) Nzdel zkeep zyes zno z%-4dbreakpoint %s at %s:%dz stop only if %sz ignore next %d hitsrrz" breakpoint already hit %d time%s)rKrrJrlr%rarr)rZdispZretZssr r r rs$  zBreakpoint.bpformatcCsd|j|j|jfS)Nzbreakpoint %s at %s:%s)rJrlr%)rr r r __str__6szBreakpoint.__str__)FNN)N)rr r r rrerprrhrrrrrr r r r rs   cCsN|js|j|jkrdSdS|jj|jkr,dS|js:|j|_|j|jkrJdSdS)z;Check whether we should break here because of `b.funcname`.FT)rbr%rFr7rr)br/r r r checkfuncname;s  rc Cstj||f}x|D]}|js qt||s,q|jd7_|jsf|jdkr\|jd8_qq|dfSqy)r-)ar r r rs rcCst}|jddS)Nzimport bdb; bdb.foo(10))rr)rr r r testsr)r rBrXrinspectrrr__all__r9 Exceptionrrr[rrrIrrrrr r r r s&  OZ0pipes.cpython-36.pyc000064400000017202151027002730010311 0ustar003 \"@spdZddlZddlZddlZddlmZdgZdZdZdZ dZ d Z d Z eee e e e gZ Gd ddZd d ZdS)aConversion pipeline templates. The problem: ------------ Suppose you have some data that you want to convert to another format, such as from GIF image format to PPM image format. Maybe the conversion involves several steps (e.g. piping it through compress or uuencode). Some of the conversion steps may require that their input is a disk file, others may be able to read standard input; similar for their output. The input to the entire conversion may also be read from a disk file or from an open file, and similar for its output. The module lets you construct a pipeline template by sticking one or more conversion steps together. It will take care of creating and removing temporary files if they are necessary to hold intermediate data. You can then use the template to do conversions from many different sources to many different destinations. The temporary file names used are different each time the template is used. The templates are objects so you can create templates for many different conversion steps and store them in a dictionary, for instance. Directions: ----------- To create a template: t = Template() To add a conversion step to a template: t.append(command, kind) where kind is a string of two characters: the first is '-' if the command reads its standard input or 'f' if it requires a file; the second likewise for the output. The command must be valid /bin/sh syntax. If input or output files are required, they are passed as $IN and $OUT; otherwise, it must be possible to use the command in a pipeline. To add a conversion step at the beginning: t.prepend(command, kind) To convert a file to another file using a template: sts = t.copy(infile, outfile) If infile or outfile are the empty string, standard input is read or standard output is written, respectively. The return value is the exit status of the conversion pipeline. To open a file for reading or writing through a conversion pipeline: fp = t.open(file, mode) where mode is 'r' to read the file, or 'w' to write it -- just like for the built-in function open() or for os.popen(). To create a new template object initialized to a given one: t2 = t.clone() N)quoteTemplateZffz-fzf-z--z.-z-.c@speZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZdS)rz'Class representing a pipeline template.cCsd|_|jdS)z-Template() returns a fresh pipeline template.rN) debuggingreset)selfr/usr/lib64/python3.6/pipes.py__init__UszTemplate.__init__cCs d|jfS)z t.__repr__() implements repr(t).z