New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Faulty dict arg gives ValueError but mostly TypeError #84509
Comments
Hello Python bug tracker Trying to create a dict with a top level set pair will fail, but how Here comes a terminal session to reproduce the behavior. The same ----------------------------------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? I searched the bug tracker on "dict typeerror valueerror" but couldn't $ python3 --version
Python 3.7.3 Best regardsTomas |
It is all correct. Note that set is unordered, so "element #0" can be 1, and can be "one". If it is 1, you get a type error. If it is "one", which is a sequence with length 3, you get a value error. |
Serhiy Storchaka <report@bugs.python.org> writes:
Yes! Thanks, sorry for the noise. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: