Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(248)

#26492: Exhausted array iterator should left exhausted

Can't Edit
Can't Publish+Mail
Start Review
Created:
1 year, 9 months ago by storchaka+cpython
Modified:
1 year, 9 months ago
Reviewers:
victor.stinner
CC:
rhettinger, haypo, larry, Benjamin Peterson, devnull_psf.upfronthosting.co.za, storchaka
Visibility:
Public.

Patch Set 1 #

Patch Set 2 #

Total comments: 8
Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Lib/test/list_tests.py View 1 1 chunk +11 lines, -0 lines 0 comments Download
Lib/test/test_array.py View 1 1 chunk +13 lines, -2 lines 2 comments Download
Lib/test/test_bytes.py View 1 2 chunks +2 lines, -0 lines 0 comments Download
Lib/test/test_iter.py View 1 1 chunk +11 lines, -0 lines 0 comments Download
Modules/arraymodule.c View 1 2 chunks +17 lines, -4 lines 6 comments Download

Messages

Total messages: 2
haypo
https://bugs.python.org/review/26492/diff/16691/Lib/test/test_array.py File Lib/test/test_array.py (right): https://bugs.python.org/review/26492/diff/16691/Lib/test/test_array.py#newcode333 Lib/test/test_array.py:333: self.assertEqual(list(a), list(self.example) + [self.outside]) Since you also modified __reduce__, ...
1 year, 9 months ago #1
storchaka_gmail.com
1 year, 9 months ago #2
https://bugs.python.org/review/26492/diff/16691/Lib/test/test_array.py
File Lib/test/test_array.py (right):

https://bugs.python.org/review/26492/diff/16691/Lib/test/test_array.py#newcod...
Lib/test/test_array.py:333: self.assertEqual(list(a), list(self.example) +
[self.outside])
On 2016/03/08 11:42:25, haypo wrote:
> Since you also modified __reduce__, can you also please test it?

This is tested above in test_iterator_pickle.

https://bugs.python.org/review/26492/diff/16691/Modules/arraymodule.c
File Modules/arraymodule.c (right):

https://bugs.python.org/review/26492/diff/16691/Modules/arraymodule.c#newcode...
Modules/arraymodule.c:2880: assert(it != NULL);
On 2016/03/08 11:42:25, haypo wrote:
> I'm not sure that this assertion is really useful, but it doesn't hurt ;-)

There are similar assertions for other iterators.

https://bugs.python.org/review/26492/diff/16691/Modules/arraymodule.c#newcode...
Modules/arraymodule.c:2888: return (*it->getitem)(ao, it->index++);
On 2016/03/08 11:42:25, haypo wrote:
> can you pleaase add an empty line for readability?

Done.

https://bugs.python.org/review/26492/diff/16691/Modules/arraymodule.c#newcode...
Modules/arraymodule.c:2921: return Py_BuildValue("N(())", func);
On 2016/03/08 11:42:25, haypo wrote:
> Hum, I don't know well the syntax for empty tuple. Is it () or (())? That's
also
> why I asked an unit test ;-)

Result is a pair of builtin iter and a tuple containing an ampty tuple: (iter,
((),)). Exhausted iterator is pickled as empty tuple iterator. See also
issue25776.
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7