This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: sys.exc_info leaks into a generator
Type: behavior Stage: needs patch
Components: Interpreter Core Versions: Python 2.7
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: barry, collinwinter, georg.brandl, jyasskin, pitrou
Priority: low Keywords: patch

Created on 2009-05-08 17:44 by jyasskin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
exc_info.patch jyasskin, 2009-05-08 17:43 New test illustrating the bug review
Messages (6)
msg87452 - (view) Author: Jeffrey Yasskin (jyasskin) * (Python committer) Date: 2009-05-08 17:43
There's an obscure bug in sys.exc_info after a yield statement.

  def test():
      def raising_generator():
              raise IndexError("inner exception")
          except IndexError:
              yield 3
              # Here, sys.exc_info() ought to refer to the inner
              # exception, but instead it refers to the outer one.
          raise ValueError("outer exception")
      except ValueError:
          for i in raising_generator(): pass

sys.exc_info gets reset even if there's no outer exception.

The attached (failing) patch highlights this problem, and tests other
sys.exc_info behavior around function calls.
msg87454 - (view) Author: Jeffrey Yasskin (jyasskin) * (Python committer) Date: 2009-05-08 17:49
I think we should _not_ backport any fix for this bug to the 2.6 series,
since any changes to user behavior would be pretty subtle. To prevent
that backport, I'd like to apply exc_info_26.patch to the 2.6 branch,
with Barry's approval.
msg87522 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-05-10 11:56
Adding some tests to check that a bug is /not/ fixed looks weird to me.
If we did that for every trunk change that we don't want to end up in
the stable branch, there'd be lots of new tests of dubious utility.

Besides, py3k isn't affected ;)
msg87523 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2009-05-10 12:06
I agree with Antoine.
msg87529 - (view) Author: Jeffrey Yasskin (jyasskin) * (Python committer) Date: 2009-05-10 16:40
Re py3k: oops, thanks for checking.

Re 2.6: Fine with me, second patch removed.
msg185424 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-03-28 10:25
Out of date now that 2.7 is also in maintenance mode.
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50220
2013-03-28 10:25:40georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg185424

resolution: out of date
2009-05-10 16:40:47jyasskinsetfiles: - exc_info_26.patch
2009-05-10 16:40:41jyasskinsetassignee: barry ->
messages: + msg87529
2009-05-10 12:06:40barrysetmessages: + msg87523
versions: - Python 2.6
2009-05-10 11:56:48pitrousetnosy: + pitrou

messages: + msg87522
versions: - Python 3.1
2009-05-08 17:49:55jyasskinsetfiles: + exc_info_26.patch

nosy: + barry
messages: + msg87454

assignee: barry
2009-05-08 17:44:00jyasskincreate