[issue4806] Function calls taking a generator as star argument can mask TypeErrors in the generator

Terry J. Reedy report at bugs.python.org
Wed Aug 4 23:08:11 CEST 2010


Terry J. Reedy <tjreedy at udel.edu> added the comment:

I verified with 3.1 the two OP cases and that generators work fine as long as they supply the correct number of values.

def f(x): return x
def broken(): return 1
print(f(*(broken() for x in (0,))))
# prints 1

Change (0,) to (0,1) the normal arg num mismatch message appears.

test_extcall tests version of Nothing() that follow both the old and new iteration protocol. It is possible that 'sequence' in meant in the broader sense of finite iterable rather that the narrow sense of
5.6. Sequence Types — str, bytes, bytearray, list, tuple, range

Since that is confusing, I would replace 'sequence' with 'finite iterable'. (Infinite iterables, obviously, are bad, just as in any other uncontrolled situation, such as "a,*b = itertools.count()".)

So, combine the correction and the suggestion above with original and diff against current trunk (py3k branch) if you can or at least 3.1.2.

----------
nosy: +terry.reedy
versions: +Python 3.2 -Python 2.5, Python 2.6, Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4806>
_______________________________________


More information about the Python-bugs-list mailing list