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 ezio.melotti
Recipients BreamoreBoy, berker.peksag, cool-RR, eric.araujo, ezio.melotti, josh.r, r.david.murray, rhettinger, serhiy.storchaka, terry.reedy
Date 2014-07-05.13:14:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1404566089.65.0.631645415987.issue21911@psf.upfronthosting.co.za>
In-reply-to
Content
The feature request sounds reasonable to me, unless someone proves that there are major (performance) issues.  However, since this has already been reported in #18162, I'm going to close it as a duplicate.

@Raymond
> The IndexError exception is commonly used for control flow.

Can you provide an example?  IME I rarely catch IndexErrors, and I usually use LBYL before accessing a random index.

> Slowing down the instantiation to add an index that no one really needs
> would be a waste.   This exception has been around for 20+ years -- if
> they were an actual need, we would have known by now.

I'm not sure the cost of adding the index is comparable with the cost of the whole instantiation.  Regarding the request itself see #1534607 and #18162.

@Ram
> Another possibility is to make the -O flag do this switch,
> though there are problems with that too.

-1

> Unfortunately I don't program in C, so I can't implement this.

It might be easier than you think.  You just need to find where the exception is defined and see what other exceptions like KeyError do.
Then you copy the code and adjust it until it doesn't segfault anymore and the tests pass.
History
Date User Action Args
2014-07-05 13:14:49ezio.melottisetrecipients: + ezio.melotti, rhettinger, terry.reedy, eric.araujo, r.david.murray, cool-RR, BreamoreBoy, berker.peksag, serhiy.storchaka, josh.r
2014-07-05 13:14:49ezio.melottisetmessageid: <1404566089.65.0.631645415987.issue21911@psf.upfronthosting.co.za>
2014-07-05 13:14:49ezio.melottilinkissue21911 messages
2014-07-05 13:14:49ezio.melotticreate