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.

Unsupported provider

classification
Title: Remove some invariant conditions and assert in ceval
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: nnorwitz, tim.peters
Priority: normal Keywords: patch

Created on 2005-02-20 21:31 by nnorwitz, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
reset_exc.patch nnorwitz, 2005-02-20 21:31 1
Messages (3)
msg47837 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2005-02-20 21:31
ISTM that if frame->f_exc_type == NULL then exc_value
and exc_traceback will also be NULL.  I didn't see that
this is documented, perhaps I missed it or there is
some case when this can occur.  If it can occur, we
shoul develop a test for it.

Assuming this condition is invariant, some
simplifications can be made in reset_exc_info which is
called once per eval_frame (on function exit).

Also, I think there is currently an extra Py_INCREF on
Py_None.  This occurs when tstate->exc_type == NULL.

This patch seems to have little to no effect on
performance.  I did measure a 0.3% speed improvement.
msg47838 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2006-05-26 18:41
Logged In: YES 
user_id=31435

Note that the patch is out of date.

I agree the invariant you deduced should hold, but in fact
it doesn't now, at least due to insane initialization
problems in exceptions.c:

http://mail.python.org/pipermail/python-dev/2006-May/065248.html

I'd like to ensure & exploit a stronger invariant:

http://mail.python.org/pipermail/python-dev/2006-May/065231.html

but that's stuck for now.  I put my work in progress on a
new branch:

svn+ssh://svn.python.org/python/branches/tim-exc_sanity

BTW, I don't agree that the incref on Py_None wasn't needed.
 Py_None is getting assigned to two new pointers
(tstate->exc_type and frame->f_exc_type), so should be
incremented twice.
msg47839 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2006-05-26 23:17
Logged In: YES 
user_id=31435

I got a very tiny bit more out of this and added it to the
trunk.  Thanks!  Note that I left in the disputed Py_INCREF.

The more ambitious tim-exc_sanity branch is looking like
more  trouble than it's worth.  
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41609
2005-02-20 21:31:32nnorwitzcreate