Skip to content

Commit

Permalink
Update decorator lineno behavior for 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
gforsyth committed Nov 19, 2019
1 parent 8fff7bc commit 2aae02d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions xonsh/parsers/v38.py
Expand Up @@ -305,3 +305,15 @@ def p_lambdef(self, p):
args = p2
p0 = ast.Lambda(args=args, body=p4, lineno=p1.lineno, col_offset=p1.lexpos)
p[0] = p0

def p_decorated(self, p):
"""decorated : decorators classdef_or_funcdef"""
p1, p2 = p[1], p[2]
targ = p2[0]
targ.decorator_list = p1
# async functions take the col number of the 'def', unless they are
# decorated, in which case they have the col of the 'async'. WAT?
if hasattr(targ, "_async_tok"):
targ.col_offset = targ._async_tok.lexpos
del targ._async_tok
p[0] = p2

0 comments on commit 2aae02d

Please sign in to comment.