[issue40329] Faulty dict arg gives ValueError but mostly TypeError

Tomas Nordin report at bugs.python.org
Sun Apr 19 10:39:04 EDT 2020


New submission from Tomas Nordin <tomasn at kth.se>:

Hello Python bug tracker

Trying to create a dict with a top level set pair will fail, but how
will it fail?

Here comes a terminal session to reproduce the behavior. The same
command is just repeated.

----------------------------------8<----------------------------------
$ python3 -c 'd = dict({1, "one"})'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: cannot convert dictionary update sequence element #0 to a sequence

# Understand, can't convert 1 to sequence.

$ python3 -c 'd = dict({1, "one"})'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: dictionary update sequence element #0 has length 3; 2 is required

# Not so helpful to me, don't understand.

$ python3 -c 'd = dict({1, "one"})'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: cannot convert dictionary update sequence element #0 to a sequence

# OK, thanks

$ python3 -c 'd = dict({1, "one"})'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: cannot convert dictionary update sequence element #0 to a sequence

$ python3 -c 'd = dict({1, "one"})'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: cannot convert dictionary update sequence element #0 to a sequence

$ python3 -c 'd = dict({1, "one"})'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: dictionary update sequence element #0 has length 3; 2 is required

# Again?
---------------------------------->8----------------------------------

I searched the bug tracker on "dict typeerror valueerror" but couldn't
find something similar. What do you think about this?

$ python3 --version
Python 3.7.3

Best regards
--
Tomas

----------
components: Library (Lib)
messages: 366781
nosy: tomnor
priority: normal
severity: normal
status: open
title: Faulty dict arg gives ValueError but mostly TypeError
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40329>
_______________________________________


More information about the Python-bugs-list mailing list