U iÛf.ã@sZdZddlmZddlmZddlmZddlmZmZm Z m Z m Z Gdd„dej ƒZ dS) zÖFixer for generator.throw(E, V, T). g.throw(E) -> g.throw(E) g.throw(E, V) -> g.throw(E(V)) g.throw(E, V, T) -> g.throw(E(V).with_traceback(T)) g.throw("foo"[, V[, T]]) will warn about string exceptions.é)Úpytree)Útoken)Ú fixer_base)ÚNameÚCallÚArgListÚAttrÚis_tuplec@seZdZdZdZdd„ZdS)ÚFixThrowTzÉ power< any trailer< '.' 'throw' > trailer< '(' args=arglist< exc=any ',' val=any [',' tb=any] > ')' > > | power< any trailer< '.' 'throw' > trailer< '(' exc=any ')' > > c Csê|j}|d ¡}|jtjkr.| |d¡dS| d¡}|dkrDdS| ¡}t|ƒrndd„|jdd…Dƒ}n d|_ |g}|d }d |krÖ|d  ¡}d|_ t ||ƒ} t | t d ƒƒt |gƒg} | t |j| ¡¡n| t ||ƒ¡dS) NÚexcz+Python 3 does not support string exceptionsÚvalcSsg|] }| ¡‘qS©)Úclone)Ú.0Úcr r ú)sz&FixThrow.transform..ééÿÿÿÿÚÚargsÚtbÚwith_traceback)ÚsymsrÚtyperÚSTRINGZcannot_convertÚgetr ZchildrenÚprefixrrrrÚreplacerZNodeZpower) ÚselfZnodeZresultsrr r rZ throw_argsrÚeZwith_tbr r rÚ transforms*      zFixThrow.transformN)Ú__name__Ú __module__Ú __qualname__Z BM_compatibleZPATTERNr!r r r rr sr N)Ú__doc__rrZpgen2rrZ fixer_utilrrrrr ZBaseFixr r r r rÚs