You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Poor error message when TypeError is raised during dict construction #116436
~/dev/cpython main λ cat z.py
import random
def foo():
yield random.randint(100) # oops, only passed in one argument
yield "value"
dict([foo() for _ in range(3)])
~/dev/cpython main λ python3.12 z.py
Traceback (most recent call last):
File "/Users/shantanu/dev/cpython/z.py", line 7, in <module>
dict([foo() for _ in range(3)])
TypeError: cannot convert dictionary update sequence element #0 to a sequence
I'd expect something like what PyPy gives:
Traceback (most recent call last):
File "/Users/shantanu/dev/cpython/z.py", line 7, in <module>
dict([foo() for _ in range(3)])
File "/Users/shantanu/dev/cpython/z.py", line 4, in foo
yield random.randint(100) # oops, only passed in one argument
^^^^^^^^^^^^^^^^^^^
TypeError: Random.randint() missing 1 required positional argument: 'b'
changed the title [-]Regression in error message when TypeError is raised during dict construction[/-][+]Poor error message when TypeError is raised during dict construction[/+]on Mar 6, 2024
Activity
[-]Regression in error message when TypeError is raised during dict construction[/-][+]Poor error message when TypeError is raised during dict construction[/+]pythongh-116436: Improve error message when TypeError occurs during d…
Rajendra1308 commentedon Mar 7, 2024
Hey @hauntsaninja I would like to work on this issue. Could you please provide more info and also what file needs to be modified?
gh-116436: Improve error message when TypeError occurs during dict up…
StanFromIreland commentedon Oct 13, 2025
Triage: Can this be closed as completed?
hauntsaninja commentedon Oct 14, 2025
Yup, this can be closed. I think I merged the PR after it went 18 months without a review