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

2011-03-06 Thread Daniel Urban
Changes by Daniel Urban : -- nosy: +durban ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.or

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

2011-03-06 Thread Daniel Urban
Daniel Urban added the comment: I think the patch isn't entirely correct. It uses PyIter_Check for detecting the case when an *iterable* raises TypeError, but that function actually checks for an *iterator*. The check on the tp_iter member mentioned by Amaury Forgeot d'Arc probably would be

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

2011-03-06 Thread Daniel Urban
Daniel Urban added the comment: I'm attaching an updated patch. Instead !PyIter_Check() this patch checks for tp_iter == NULL && !PySequence_Check. If this condition is false, PyObject_GetIter has a chance to succeed (and if it fails, we shouldn't mask the exception). I also added more test

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

2011-04-29 Thread Terry J. Reedy
Terry J. Reedy added the comment: #11944 is probably a duplicate of this and should be checked when this is fixed -- ___ Python tracker ___ __

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

2010-05-03 Thread Bruce Frederiksen
Bruce Frederiksen added the comment: I have also hit this error. I went to report it but found it already entered (good news), but not resolved from nearly a year ago (bad news). The error masked another bug that I had in my program and it took me quite awhile to figure out what the real pro

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

2010-05-03 Thread Alexander Belopolsky
Changes by Alexander Belopolsky : -- keywords: +needs review stage: -> patch review ___ Python tracker ___ ___ Python-bugs-list mailin

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

2010-08-04 Thread Terry J. Reedy
Terry J. Reedy 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 m

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

2010-08-05 Thread Hagen Fürstenau
Hagen Fürstenau added the comment: IIUC, the only change you suggest for my patch is using "finite iterable" instead of "sequence" or "iterable", right? I've looked at the docs and there seems to be no precedent for "finite iterable". I think it's just as obvious that the iterable has to yiel

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

2010-08-05 Thread Terry J. Reedy
Terry J. Reedy added the comment: Ok, leave iterable as is. More important, you have two disjoint patches that I believe should be combined. -- ___ Python tracker ___ __

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

2010-08-05 Thread Hagen Fürstenau
Hagen Fürstenau added the comment: Attaching a combined patch against the current py3k. -- Added file: http://bugs.python.org/file18404/combined.patch ___ Python tracker ___

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

2009-01-02 Thread Hagen Fürstenau
New submission from Hagen Fürstenau : If we call some function f with a generator as star argument and this generator raises a TypeError, we get the following exception: >>> def f(x): pass ... >>> def broken(): raise TypeError ... >>> f(*(broken() for x in (0,))) Traceback (most recent call la

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

2009-01-02 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: The issue1615 has the same kind of problems: an AttributeError is masked by another one. -- nosy: +amaury.forgeotdarc ___ Python tracker _

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

2009-01-03 Thread Hagen Fürstenau
Hagen Fürstenau added the comment: I'm getting confused about whether it's actually desired behaviour that generators can be star arguments. The error message seems to say it's not: "argument after * must be a sequence". The docs seem to agree: "If the syntax *expression appears in the function

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

2012-11-28 Thread Chris Kaynor
Changes by Chris Kaynor : -- nosy: +DragonFireCK ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

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

2009-06-02 Thread Kenneth Arnold
Kenneth Arnold added the comment: I can confirm that (a) this exact behavior is happening and (b) it quite confused me (most of the time it works!). What would be a "good" TypeError? I'd vote for generators to be explicitly supported even if it required a special case. Thanks! -- nosy:

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

2009-06-03 Thread Hagen Fürstenau
Hagen Fürstenau added the comment: I added a simple check for iterables. This is not very elegant, but performance is only affected in the case of an exception. Patch and corresponsing test are attached as "TypeError.patch". As I pointed out above, the actual error message "must be a sequence"

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

2009-06-03 Thread Hagen Fürstenau
Changes by Hagen Fürstenau : Added file: http://bugs.python.org/file14167/message_and_docs.patch ___ Python tracker ___ ___ Python-bugs-list ma

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

2009-06-03 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc added the comment: This patch leaks a reference on each call to PyObject_GetIter(). And I'm not sure it is a good idea to call this function again: it may be very expensive! I'd prefer a simple check on the tp_iter member. -- ___

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

2009-06-03 Thread Hagen Fürstenau
Hagen Fürstenau added the comment: Sorry, I had meant to use PyIter_Check instead of PyObject_GetIter. Don't know why I didn't do so... ;-) I corrected the patch. -- Added file: http://bugs.python.org/file14169/TypeError2.patch ___ Python tracker <

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

2009-06-03 Thread Hagen Fürstenau
Changes by Hagen Fürstenau : Removed file: http://bugs.python.org/file14166/TypeError.patch ___ Python tracker ___ ___ Python-bugs-list mailing

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

2016-04-16 Thread Roundup Robot
Roundup Robot added the comment: New changeset eef8f72ddb00 by Martin Panter in branch '2.7': Issue #4806: Avoid masking TypeError when *-unpacking a generator https://hg.python.org/cpython/rev/eef8f72ddb00 -- ___ Python tracker

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

2016-04-16 Thread Martin Panter
Changes by Martin Panter : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ ___ P

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

2015-02-23 Thread Martin Panter
Martin Panter added the comment: I am posting a new version of Daniel’s patch as issue4806-star-TypeError.v2.patch: * Merged with recent “default” (3.5) branch * Dropped the documentation fix, since revision a8aa918041c2 already fixed that in an identical fashion * Changed to a “look before yo

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

2016-01-20 Thread Samuel BOVÉE
Samuel BOVÉE added the comment: Up for this bug. I got this bug in my code and loose one hour to understand what happened. Please review Martin's patch ! -- nosy: +Samuel BOVÉE ___ Python tracker __

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

2016-01-22 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: +yselivanov ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

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

2016-01-29 Thread Martin Panter
Martin Panter added the comment: I think this is ready to push for Python 3. Python 2 might need an extra Py_TPFLAGS_HAVE_ITER check, perhaps reusing some code from the Issue 5218 patch. -- stage: patch review -> commit review versions: +Python 3.6 -Python 3.4 _

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

2016-01-30 Thread Roundup Robot
Roundup Robot added the comment: New changeset 1a8dc350962b by Martin Panter in branch '3.5': Issue #4806: Avoid masking original TypeError in call with * unpacking https://hg.python.org/cpython/rev/1a8dc350962b New changeset 1261f5f6fc95 by Martin Panter in branch 'default': Issue #4806: Merge

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

2016-01-30 Thread Martin Panter
Martin Panter added the comment: In Python 2, the old-style “instance” objects are making it hard to fix this like in Python 3. And completely removing the custom error message seems a bit drastic for 2.7. Instead, I propose to just check for a generator type after the TypeError is caught, an

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

2016-02-15 Thread Michel Desmoulin
Michel Desmoulin added the comment: It gets even weirder with coroutines involved: >>> f = (coro() for coro in l) >>> asyncio.gather(*f) # TypeError: asyncio.gather() argument after * must be a >>> sequence, not generator >>> asyncio.gather(*[*f]) # ok Because coroutines are executed later,

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

2016-02-15 Thread Martin Panter
Martin Panter added the comment: Michel: I suspect your code doesn’t actually get up to handling any coroutines, and the problem is in your generator expression. What is “l”, and what are the items in it? The bug should already be fixed ready for the 3.5.2 and 3.6 releases, but I can produce t

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

2016-02-15 Thread Michel Desmoulin
Michel Desmoulin added the comment: We fixed our bug days ago, but I would have expected [*gen] to have triggered an exception before it even got to gather(). The real code was something like: >>> l = (ensure_awaitable(callable_obj) for callable_obj in callable_list) >>> gather(*l) ensure_awa

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

2014-02-18 Thread pfctdayelise
Changes by pfctdayelise : -- nosy: +pfctdayelise ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

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

2014-03-19 Thread R. David Murray
R. David Murray added the comment: Sounds like we just need someone comfortable with modifying ceval.c to apply this ;) -- nosy: +benjamin.peterson, r.david.murray versions: +Python 3.4, Python 3.5 -Python 3.2, Python 3.3 ___ Python tracker

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

2012-01-11 Thread Martin Panter
Changes by Martin Panter : -- nosy: +vadmium ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

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

2012-01-11 Thread Martin Panter
Martin Panter added the comment: I haven’t tried to understand what the patches do, but Issue 5218 looks like a very similar problem with a patch including a test case. -- ___ Python tracker __

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

2012-02-03 Thread Terry J. Reedy
Terry J. Reedy added the comment: #13904 is another dup, with patches to test and ceval. I asked that they be reloaded to this issue. -- nosy: +ncoghlan versions: -Python 3.1 ___ Python tracker __

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

2012-02-03 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- nosy: +ron_adam ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pytho

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

2012-02-03 Thread Terry J. Reedy
Terry J. Reedy added the comment: #5218 is a 4th duplicate, also with a patch to the ceval loop and test. -- nosy: +georg.brandl, gpolo, pitrou ___ Python tracker ___ ___

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

2012-02-03 Thread Terry J. Reedy
Terry J. Reedy added the comment: Sorry Martin, I see you already said that. Anyway, I closed other three in favor of this one. -- ___ Python tracker ___ ___

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

2012-02-27 Thread Jon Brandvein
Changes by Jon Brandvein : -- nosy: +brandj ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

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

2018-04-16 Thread Jason R. Coombs
Jason R. Coombs added the comment: I believe I encountered this issue today on Python 2.7.14 (https://ci.appveyor.com/project/jaraco/jaraco-windows/build/31/job/lenh5l4dcmj137b9). In this case, I have an iterable (in itertools.imap) that raises a TypeError when evaluated, not a generator. Th