You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix bare excepts in various places in std lib #60465
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/serhiy-storchaka'closed_at=<Date2015-05-20.07:35:47.678>created_at=<Date2012-10-17.08:06:05.258>labels= ['type-bug', 'library']
title='Fix bare excepts in various places in std lib'updated_at=<Date2015-05-20.07:35:47.677>user='https://bugs.python.org/RamchandraApte'
One thing to be aware of, Ramchandra, is that there might be a slight backwards-compatibility problem from tightening up what exceptions propagate. Now with proper documentation and only applying things to 3.4 this probably won't be a problem.
This seems quite difficult for one person;there are 589 lines having "except:"
I'll work on the Tools directory.
If anybody wants to help, please tell which folder you will do.
I've fixed bare except: in docs.
Tomorrow we will have Python sprint in Kiev.
Maybe somebody will take a look on Lib.
RamchandraApte commented on Jan 9, 2013
RamchandraAptemannequin
MannequinAuthor
More actions
Here's a patch on revision 75fe7f5fda9a (I did it on a trip without an internet connection)
There might be some mistakes of this type:
I incorrectly changed instances like this try: something except: close file raise
to try: something finally: close file
(the incorrect version closes the file always)
RamchandraApte commented on Jan 9, 2013
RamchandraAptemannequin
MannequinAuthor
More actions
Sorry, I entered the wrong filename for the patch and so it didn't get attached. Now I have attached it.
Want to make a few warnings. Accepting your confirmation may take a long time. And it is very unlikely that your patch can be applied as a whole. The maintainers of the individual modules can apply it by parts.
The earlier bpo-15313 is about removing bare excepts in Idle code. These should be handled separately for two reasons.
Changes can and in most cases should be backported.
As with any other Python-coded application, uncaught exceptions cause Idle to quit. Currently, if Idle is started directly, rather than from a console, such an exit looks like a silent crash. So either the added tuple of exceptions to be caught must be complete, or the calling code must be adjusted.
I copied the one idlelib fix (to PyShell.py) to that issue for separate examination. It should be removed from any patch applied here.
I reviewed the patch on Reitveld. All of the changes that do not have comments look okay to me, although some will definitely have merge conflicts with the current code. If someone updated the patch based on the comments, I think it may be okay to commit.
Activity
RamchandraApte commentedon Oct 17, 2012
Will attach patch.
brettcannon commentedon Oct 17, 2012
One thing to be aware of, Ramchandra, is that there might be a slight backwards-compatibility problem from tightening up what exceptions propagate. Now with proper documentation and only applying things to 3.4 this probably won't be a problem.
RamchandraApte commentedon Oct 31, 2012
This seems quite difficult for one person;there are 589 lines having "except:"
I'll work on the Tools directory.
If anybody wants to help, please tell which folder you will do.
asvetlov commentedon Nov 1, 2012
I'm pretty sure Doc and Lib are already fixed, only Tools left.
RamchandraApte commentedon Nov 1, 2012
On 1 November 2012 17:21, Andrew Svetlov <report@bugs.python.org> wrote:
No. 405 are there in Lib. Try running
grep "except:" -R Lib --include "*.py"to see yourself.asvetlov commentedon Nov 1, 2012
Sorry, looks like I don't understood you correctly.
Do you want to replace `except:` to `except Exception` or something else?
RamchandraApte commentedon Nov 2, 2012
Yes.
most of the bare excepts can be replaced with a stricter clause
On 2 November 2012 01:06, Andrew Svetlov <report@bugs.python.org> wrote:
python-dev commentedon Nov 2, 2012
New changeset b2bd62d1644f by Andrew Svetlov in branch 'default':
Issue bpo-16261: fix bare excepts in Doc/
http://hg.python.org/cpython/rev/b2bd62d1644f
asvetlov commentedon Nov 2, 2012
I've fixed bare except: in docs.
Tomorrow we will have Python sprint in Kiev.
Maybe somebody will take a look on Lib.
RamchandraApte commentedon Jan 9, 2013
Here's a patch on revision 75fe7f5fda9a (I did it on a trip without an internet connection)
There might be some mistakes of this type:
I incorrectly changed instances like this
try: something except: close file raiseto
try: something finally: close file(the incorrect version closes the file always)
RamchandraApte commentedon Jan 9, 2013
Sorry, I entered the wrong filename for the patch and so it didn't get attached. Now I have attached it.
serhiy-storchaka commentedon Jan 9, 2013
Unhappy Rietveld hasn't recognize your patch. I have regenerated it.
sbt commentedon Jan 9, 2013
os.sysconf() might raise OSError. I think ValueError is only raised if _SC_OPEN_MAX was undefined when the module was compiled.
serhiy-storchaka commentedon Jan 9, 2013
See my comments on Rietveld.
serhiy-storchaka commentedon Jan 9, 2013
Want to make a few warnings. Accepting your confirmation may take a long time. And it is very unlikely that your patch can be applied as a whole. The maintainers of the individual modules can apply it by parts.
terryjreedy commentedon Nov 8, 2013
The earlier bpo-15313 is about removing bare excepts in Idle code. These should be handled separately for two reasons.
I copied the one idlelib fix (to PyShell.py) to that issue for separate examination. It should be removed from any patch applied here.
terryjreedy commentedon Apr 18, 2014
See more discussion on duplicate bpo-21259.
vadmium commentedon May 20, 2015
I reviewed the patch on Reitveld. All of the changes that do not have comments look okay to me, although some will definitely have merge conflicts with the current code. If someone updated the patch based on the comments, I think it may be okay to commit.
python-dev commentedon May 20, 2015
New changeset b3a7215b9ce4 by Serhiy Storchaka in branch 'default':
Issue bpo-16261: Converted some bare except statements to except statements
https://hg.python.org/cpython/rev/b3a7215b9ce4
serhiy-storchaka commentedon May 20, 2015
Resolved conflicts, fixed some noted issues in the patch and committed unquestionable changes. Thank you for your patch Ramchandra.