[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2018-09-02 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2018-09-02 Thread Lorenz Mende


Lorenz Mende  added the comment:

This issue shall be closed, as the solution is already on master with 
4171bbe687904582329c7977d571686953275b45.

--
nosy: +LorenzMende

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-15 Thread Arnon Yaari

Changes by Arnon Yaari wiggi...@gmail.com:


Removed file: http://bugs.python.org/file39011/issue23949.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-15 Thread Skip Montanaro

Skip Montanaro added the comment:

I like the idea of the too many and not enough messages being symmetric. If 
it's not too hard, I would prefer them to both identify the number of expected 
and received values. I don't have a recent checkout at hand though, so it's 
non-trivial for me to produce a patch. The best I can do easily is toss peanuts 
from the gallery.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-15 Thread Arnon Yaari

Arnon Yaari added the comment:

I couldn't find a way to add 'got %d' to the 'too many values' message. This 
would either require going over the rest of the iterator (which will take more 
time and may never return) or trying to figure out if it has a 'len' member. I 
didn't find any place in the current code that does something like this and 
writing one myself is too error prone (there are so many cases...). 
PyObject_Size returns an error if I try to use it for this purpose.

I found another message with need more than ... that I improved in the same 
way. This message is for when trying to execute:
   a, *(b, c, d) = 1, (2, 3), (4, 5)
Now it outputs the message for the star unpacking:
  ValueError: not enough values to unpack (expected 3, got 2)
which is confusing in this use case but still better than before. Oh my!

--
Added file: http://bugs.python.org/file39039/issue23949.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-15 Thread Arnon Yaari

Changes by Arnon Yaari wiggi...@gmail.com:


Added file: http://bugs.python.org/file39042/issue23949-2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-15 Thread Arnon Yaari

Arnon Yaari added the comment:

I fixed the tests (that's important!) and changed the latter message to specify 
it is referring to the starred target (the term starred target appears in the 
docs in simple_stmts.rst). Looks like the number in that message was wrong 
before!
The test looked like this:

   a, *b, c, d, e = 0, 1, 2
  ValueError: need more than 3 values to unpack

Need more than 3? Not exactly.

The new message looks like this:
   a, *b, c, d, e = 0, 1, 2
  ValueError: not enough values to unpack into starred target (expected at 
least 4, got 3)

--
Added file: http://bugs.python.org/file39041/issue23949-1.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-15 Thread Arnon Yaari

Changes by Arnon Yaari wiggi...@gmail.com:


Added file: http://bugs.python.org/file39043/issue23949-3.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-15 Thread Arnon Yaari

Arnon Yaari added the comment:

Sorry, I got confused (which proves the point of the ticket :))
* the need more than 3 values error message wasn't wrong, just confusing.
* Including into starred target in the message was incorrect, I removed it.
* The message with expected at least ... (when there is a star target) didn't 
show if there weren't enough values to fill the arguments before the star 
argument. I fixed this now too and added a test.

--
Added file: http://bugs.python.org/file39046/issue23949-4.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e55cc0834e9c by R David Murray in branch 'default':
#23949: Improve tuple unpacking error messages.
https://hg.python.org/cpython/rev/e55cc0834e9c

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-14 Thread Ulaga Nathan Mahadevan

Ulaga Nathan Mahadevan added the comment:

I agree. I posted it as an enhancement request. Steven explained the
expected message clearly. Thanks.

On Tue, Apr 14, 2015 at 12:58 PM, Steven D'Aprano rep...@bugs.python.org
wrote:


 Steven D'Aprano added the comment:

 The error message isn't wrong, just hard to understand. In your example,
 when it says need more than 4 values to unpack it means that it got four
 values on the right hand side, and needs five (which is more than four) to
 match what is on the left.

 When the error is the other way around, with too few targets on the left,
 the error message is more understandable:

 a, b = (1, 2, 3)

 gives

 ValueError: too many values to unpack (expected 2).

 Your example should be fixed to something similar. I think it would be
 useful for both cases to report expected %d, got %d rather than just one
 or the other.


 By the way, I don't think that changes to error messages will be
 back-ported to old versions like 3.2, but only added to the latest version.

 --
 keywords: +easy
 nosy: +steven.daprano

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue23949
 ___


--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-14 Thread Ulaga Nathan Mahadevan

New submission from Ulaga Nathan Mahadevan:

data = ['David',50,91.1,(2012,12,21)]
print (Data = ,data)
name,shares,price,date,value = data

print(Name = ,name, , no of shares = ,shares,, unit price = ,price,, 
date of purchase = ,date)

After running the script
Data =  ['David', 50, 91.1, (2012, 12, 21)]
name,shares,price,date,value = data
ValueError: need more than 4 values to unpack

There are only 4 values to unback and not more than 4. The given number of 
elements are 4 and so required number is 4. The error message is not clear or 
confusing.

--
messages: 240935
nosy: ulaganathanm...@gmail.com
priority: normal
severity: normal
status: open
title: Number of elements display in error message is wrong while unpacking in 
traceback
type: enhancement
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-14 Thread Skip Montanaro

Skip Montanaro added the comment:

I'm not sure I understand the problem is. You have a list containing four 
values, and try to unpack it into five individual objects. There is no element 
in the list data to assign the name value.

--
nosy: +skip.montanaro

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-14 Thread Steven D'Aprano

Steven D'Aprano added the comment:

The error message isn't wrong, just hard to understand. In your example, when 
it says need more than 4 values to unpack it means that it got four values on 
the right hand side, and needs five (which is more than four) to match what is 
on the left.

When the error is the other way around, with too few targets on the left, the 
error message is more understandable:

a, b = (1, 2, 3)

gives

ValueError: too many values to unpack (expected 2).

Your example should be fixed to something similar. I think it would be useful 
for both cases to report expected %d, got %d rather than just one or the 
other.


By the way, I don't think that changes to error messages will be back-ported to 
old versions like 3.2, but only added to the latest version.

--
keywords: +easy
nosy: +steven.daprano

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-14 Thread Martin Panter

Martin Panter added the comment:

Either option would be an improvement. I think I prefer issue23949.diff by 
Arnon. I guess it would then look like this:

 name,shares,price,date,value = data
Traceback (most recent call last):
  File stdin, line 1, in module
ValueError: not enough values to unpack (expected 5, got 4)

--
nosy: +vadmium

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-14 Thread William Orr

William Orr added the comment:

I've updated the error message to just include the expected number of 
arguments. I think this makes it way more readable.

--
keywords: +patch
nosy: +worr
Added file: http://bugs.python.org/file39010/maxvalueerror.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23949] Number of elements display in error message is wrong while unpacking in traceback

2015-04-14 Thread Arnon Yaari

Arnon Yaari added the comment:

Adding alternative patch for suggestion.

--
nosy: +wiggin15
versions: +Python 3.5 -Python 3.2
Added file: http://bugs.python.org/file39011/issue23949.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23949
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com