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|st|d}|d}|d}|rz|jrF|td|jdn2dd|D}d|d _|ttd |jd|n|rtd|jd}||nl|rt|r|d }dd d|D d kr| |t dS|tdnd|kr| |t d|_dS)Nbaseattrname__next__)prefixcSsg|] }|qSr)Zclone.0rrrr 9sz%FixNext.transform..r headcSsg|] }t|qSr)strrrrrrEsZ __builtin__globalT) AssertionErrorgetrreplacerrris_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)r2symsZ expr_stmtZ simple_stmtparentr0r)rrrr0]s  r0cs$|kr dStfdd|jDS)NTc3s|]}t|VqdSr5)r4)rcr8rr gszis_subtree..)anyr1)rootr)rr8rr4dsr4N)__doc__Zpgen2rZpygramrr6rrZ fixer_utilrrrr ZBaseFixrr&r0r4rrrrs   @