Title: generator.throw() documentation inaccurate
Type: Stage: needs patch
Components: Documentation Versions: Python 3.6, Python 3.5, Python 3.4, Python 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, kristjan.jonsson, martin.panter, yselivanov
Priority: normal Keywords: patch

Created on 2012-05-25 11:02 by kristjan.jonsson, last changed 2015-06-20 12:00 by martin.panter.

File name Uploaded Description Edit
throw27.diff kristjan.jonsson, 2014-02-03 15:19
3x.diff kristjan.jonsson, 2014-02-03 15:57 review
Messages (7)
msg161565 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2012-05-25 11:02
the documentation for generator.throw() does not mention the fact that it has the same semantics for the three arguments as a "raise" expression has.
The first two arguments can be:
throw(exc_type, None)
throw(exc_type, value)
throw(exc_type, exc_instance)
throw(exc_instance, None)
msg209836 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2014-01-31 22:11
Kristjan, can you write a patch for this?
msg210139 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2014-02-03 15:19
Here's one for 2.7.  I'm still looking at 3.  The funny thing is that the signature of generator.throw reflects 2.x conventions.  I'm figuring out if it can be used with the .with_traceback() idiom
msg210146 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2014-02-03 15:57
And 3.x
msg210150 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2014-02-03 17:35
I like the patches, except the example in 3x.diff. Please see the review.
msg210188 - (view) Author: Kristján Valur Jónsson (kristjan.jonsson) * (Python committer) Date: 2014-02-04 09:45
Note that the docstring does not match the doc:
"throw(typ[,val[,tb]]) -> raise exception in generator,\n\
return next yielded value or raise StopIteration.");

Should I change the docstring too?
msg245559 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-06-20 12:00
See Issue 13213 for some analysis of the behaviour of different combinations of arguments.

The docstring should be changed if necessary, but in this case I don’t see what needs changing. The argument names perhaps, just for consistency’s sake?
Date User Action Args
2015-06-20 12:02:41martin.panterlinkissue13213 superseder
2015-06-20 12:00:48martin.pantersetnosy: + martin.panter

messages: + msg245559
versions: + Python 3.4, Python 3.5, Python 3.6, - Python 3.2, Python 3.3
2014-02-04 09:45:12kristjan.jonssonsetmessages: + msg210188
2014-02-03 17:35:14yselivanovsetmessages: + msg210150
2014-02-03 15:57:37kristjan.jonssonsetfiles: + 3x.diff

messages: + msg210146
2014-02-03 15:19:58kristjan.jonssonsetfiles: + throw27.diff
keywords: + patch
messages: + msg210139
2014-01-31 22:11:27yselivanovsetnosy: + yselivanov
messages: + msg209836
2012-05-25 18:42:09eric.araujosetstage: needs patch
versions: - Python 3.1, Python 3.4
2012-05-25 11:02:16kristjan.jonssoncreate