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 amaury.forgeotdarc
Recipients amaury.forgeotdarc, dominic.lavoie
Date 2008-07-09.22:02:35
SpamBayes Score 6.889346e-05
Marked as misclassified No
Message-id <1215640957.49.0.754727920482.issue3328@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks for the short case. It makes everything simpler.
First, note that you get the same behaviour with python-only code:

import re, sys
class Issue3328:
    def f(self):
        # unbalanced parenthesis
        x = re.compile('(123')

o = Issue3328()
sys.getrefcount(o)      # prints 2
o.f()
sys.getrefcount(o)      # prints 3

And this is normal: the last exception contains the traceback (stored in
sys.last_traceback) which contains the live context frames which
reference the "self" variable which is the additional reference to our
object.
Try to provoke another error (any SyntaxError will do) and see the
refcount decrease.

Now, the three variables sys.last_traceback, sys.last_type and
sys.last_value contain the info about the last *uncaught* exception.
An exception is said to be *uncaught* when PyErr_Print() is called to
print it... That's what happens at the interactive prompt, of course,
and in your C code.

Looking at python source code, PyErr_Print() is actually a single call
to PyErr_PrintEx(1), the parameter (1) is named "set_sys_last_vars"
(aha!). You should try to call PyErr_PrintEx(0) instead, and see if this
improves something.

Then a documentation path will be very welcomed ;-)
History
Date User Action Args
2008-07-09 22:02:37amaury.forgeotdarcsetspambayes_score: 6.88935e-05 -> 6.889346e-05
recipients: + amaury.forgeotdarc, dominic.lavoie
2008-07-09 22:02:37amaury.forgeotdarcsetspambayes_score: 6.88935e-05 -> 6.88935e-05
messageid: <1215640957.49.0.754727920482.issue3328@psf.upfronthosting.co.za>
2008-07-09 22:02:36amaury.forgeotdarclinkissue3328 messages
2008-07-09 22:02:35amaury.forgeotdarccreate