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.

Author ncoghlan
Recipients aronacher, catalin.iacob, draghuram, eric.araujo, ethan.furman, ezio.melotti, mrabarnett, ncoghlan, pitrou, poke, rhettinger, steven.daprano
Date 2012-01-29.08:04:31
SpamBayes Score 2.02598e-09
Marked as misclassified No
Message-id <>
Ah, nice idea of bringing the boolean constants into the mix so we don't need to invent a new sentinel value.

However, to preserve the current behaviour that "raise X from Y" is essentially just syntactic sugar for: "_var = X; _var.__cause__ = Y; raise Y", I suggest setting the default value for "__cause__" to "False" (indicating "not set"). Then:

  "__cause__ is False" means "no cause set, display context"
  "__cause__ is None" means "cause explicitly set to None, suppress context"
  Any other value means "display cause"

The default value for cause is controlled by get_cause and set_cause in exceptions.c [1]. The basic idea would be to replace the current usage of Py_None and Py_RETURN_NONE in that code with Py_False and Py_RETURN_FALSE, and then change the criteria for valid causes to "arg != Py_None && !PyExceptionInstance_Check(arg)".

In addition to the files already touched by the patch, Lib/ [2] and its tests will also require updating.

Date User Action Args
2012-01-29 08:04:33ncoghlansetrecipients: + ncoghlan, rhettinger, pitrou, draghuram, aronacher, ezio.melotti, eric.araujo, mrabarnett, steven.daprano, poke, ethan.furman, catalin.iacob
2012-01-29 08:04:33ncoghlansetmessageid: <>
2012-01-29 08:04:32ncoghlanlinkissue6210 messages
2012-01-29 08:04:31ncoghlancreate