This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Traceback contains incorrect line number for duplicate argument in lambda definition
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, james.lingard
Priority: normal Keywords:

Created on 2009-11-20 00:36 by james.lingard, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg95518 - (view) Author: James Lingard (james.lingard) Date: 2009-11-20 00:36
The following python file:

  lambda a, a: 0

when executed gives the following backtrace:

    File "/tmp/test.py", line 0
  SyntaxError: duplicate argument 'a' in function definition

Note that the line number is 0, not 1.  (It's always 0, regardless of
the position in the file).

---

Note that this doesn't happen for other similar errors in lambda
functions, for example the file:

  lambda a=0, a: 0

leads to the following error message:

    File "/tmp/test.py", line 1
      lambda a=0, a: 0
  SyntaxError: non-default argument follows default argument

and it also doesn't happen for the same error in a 'def':

  def f(a, a): pass

leads to the following error message:

    File "/tmp/test.py", line 1
      def f(a, a): pass
  SyntaxError: duplicate argument 'a' in function definition

---

Tested on Python 2.6 (r26:66714, Jun  8 2009, 16:07:29).
msg95519 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-11-20 01:17
Fixed in r76423.
History
Date User Action Args
2022-04-11 14:56:54adminsetgithub: 51613
2009-11-20 01:17:18benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg95519

resolution: fixed
2009-11-20 00:36:23james.lingardcreate