Skip to content

Commit 049dbb9

Browse files
committed
unpythonic.syntax.util.wrapwith: look inside Done et al.
1 parent fd86957 commit 049dbb9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

unpythonic/syntax/util.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from ast import (Call, Lambda, FunctionDef, AsyncFunctionDef,
77
If, With, withitem, stmt, NodeTransformer)
88

9+
import mcpyrate.markers
910
from mcpyrate.walkers import ASTTransformer, ASTVisitor
1011

1112
from .astcompat import getconstant
@@ -410,6 +411,8 @@ def wrapwith(item, body, locref=None):
410411
411412
Syntax transformer. Returns the wrapped body.
412413
"""
414+
if isinstance(locref, mcpyrate.markers.ASTMarker): # unwrap contents of Done() et al.
415+
locref = locref.body
413416
locref = locref or body[0]
414417
wrapped = With(items=[withitem(context_expr=item, optional_vars=None)],
415418
body=body,

0 commit comments

Comments
 (0)