Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d9f5e4

Browse files
committed
more robust assignment of lineno for keyword args
get the lineno from the name of the keyword arg example of case that didn't work-- def foo(x, y, a = None, b = None):
1 parent 2ce27b2 commit 3d9f5e4

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Lib/compiler/transformer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -993,9 +993,9 @@ def com_argument(self, nodelist, kw):
993993
n = n[1]
994994
if n[0] != token.NAME:
995995
raise SyntaxError, "keyword can't be an expression (%s)"%n[0]
996-
n = Node('keyword', n[1], result)
997-
n.lineno = result.lineno
998-
return 1, n
996+
node = Node('keyword', n[1], result)
997+
node.lineno = n[2]
998+
return 1, node
999999

10001000
def com_subscriptlist(self, primary, nodelist, assigning):
10011001
# slicing: simple_slicing | extended_slicing

Tools/compiler/compiler/transformer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -993,9 +993,9 @@ def com_argument(self, nodelist, kw):
993993
n = n[1]
994994
if n[0] != token.NAME:
995995
raise SyntaxError, "keyword can't be an expression (%s)"%n[0]
996-
n = Node('keyword', n[1], result)
997-
n.lineno = result.lineno
998-
return 1, n
996+
node = Node('keyword', n[1], result)
997+
node.lineno = n[2]
998+
return 1, node
999999

10001000
def com_subscriptlist(self, primary, nodelist, assigning):
10011001
# slicing: simple_slicing | extended_slicing

0 commit comments

Comments
 (0)