U iff @sndZddlmZddlmZddlmZddlm Z m Z m Z dZ Gdddej Zd d Zd d Zd dZdS)z.Fixer for it.next() -> next(it), per PEP 3114.)token)python_symbols) fixer_base)NameCall find_bindingz;Calls to builtin next() possibly shadowed by global bindingcs0eZdZdZdZdZfddZddZZS)FixNextTa power< base=any+ trailer< '.' attr='next' > trailer< '(' ')' > > | power< head=any+ trailer< '.' attr='next' > not trailer< '(' ')' > > | classdef< 'class' any+ ':' suite< any* funcdef< 'def' name='next' parameters< '(' NAME ')' > any+ > any* > > | global=global_stmt< 'global' any* 'next' any* > Zprecs>tt|||td|}|r4||td|_nd|_dS)NnextTF)superr start_treerwarning bind_warning shadowed_next)selfZtreefilenamen __class__;/opt/alt/python38/lib64/python3.8/lib2to3/fixes/fix_next.pyr $s   zFixNext.start_treecCs|d}|d}|d}|rr|jr>|td|jdqdd|D}d|d _|ttd |jd|n|rtd|jd}||nj|rt|r|d }dd d|Dd kr| |t dS|tdnd|kr| |t d|_dS)Nbaseattrname__next__)prefixcSsg|] }|qSr)Zclone.0rrrr 9sz%FixNext.transform..r headcSsg|] }t|qSr)strrrrrrEsZ __builtin__globalT) getrreplacerrris_assign_targetjoinstripr r )rnodeZresultsrrrrr rrr transform.s,       zFixNext.transform) __name__ __module__ __qualname__Z BM_compatibleZPATTERNorderr r) __classcell__rrrrrs  rcCsFt|}|dkrdS|jD]&}|jtjkr0dSt||rdSqdS)NFT) find_assignchildrentyperEQUAL is_subtree)r(ZassignZchildrrrr%Qs   r%cCs4|jtjkr|S|jtjks&|jdkr*dSt|jSN)r1symsZ expr_stmtZ simple_stmtparentr/r(rrrr/]s  r/cs$|kr dStfdd|jDS)NTc3s|]}t|VqdSr4)r3)rcr7rr gszis_subtree..)anyr0)rootr(rr7rr3dsr3N)__doc__Zpgen2rZpygramrr5rrZ fixer_utilrrrr ZBaseFixrr%r/r3rrrrs   @