[issue9608] Re-phrase best way of using exceptions in doanddont.rst

2010-09-11 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Committed in r84719 and r84720, backported to 2.7 in r84721 with the addition 
of a sentence admitting that sometimes you need a bare except to catch 
third-party exceptions that don't inherit from Exception.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9608
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9608] Re-phrase best way of using exceptions in doanddont.rst

2010-09-11 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Nice, thanks!

--
resolution: fixed - 
stage: committed/rejected - patch review
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9608
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9608] Re-phrase best way of using exceptions in doanddont.rst

2010-09-11 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9608
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9608] Re-phrase best way of using exceptions in doanddont.rst

2010-09-10 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Here is another edit pass, incorporating Éric's suggestions and adding some 
additional tweaks.  In particular, I eliminated the anti-pattern of catching 
(IOError, OSError) in one of the earlier examples in favor of the correct 
EnvironmentError, and also improved the error message generated in that case :)

--
Added file: http://bugs.python.org/file18843/doanddont-except.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9608
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9608] Re-phrase best way of using exceptions in doanddont.rst

2010-09-07 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Here is a more extensive rewrite that I think makes things clearer and (I hope) 
makes the text read better.  I also updated the preceding section per the 
confusion expressed in issue 8518.

Note that this patch is somewhat Python3 specific, since it assumes that all 
non-BaseException exceptions inherit from Exception.  If someone wants to 
backport it to 2.7 a paragraph or footnote should be added about that problem.

Opinions welcome.

--
nosy: +r.david.murray
Added file: http://bugs.python.org/file18791/doanddont-except.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9608
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9608] Re-phrase best way of using exceptions in doanddont.rst

2010-09-07 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Your rewrite makes the text much clearer in my opinion. Here are some nits for 
you to grind, cheers :)

1) I’d say “using a bare ``except:``” and maybe add an index entry for “bare 
except” referring to that section, to make indexing and maybe googling find 
this.

2) To make the bad examples clearer, I would remove the second inline comment 
(“will be changed as soon as we run it”). The wording is confusing: Does that 
mean the code will be changed by Python at runtime? The text after this code 
example is clear enough, this comment doesn’t help.

3) “except catches all errors, including GeneratorExit which is not even an 
error”: Isn’t this confusing for beginners?

--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9608
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9608] Re-phrase best way of using exceptions in doanddont.rst

2010-09-07 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

(1) and (2) are good ideas.  For (3), would it be clear enough if it read 
``except:`` catches *all* exceptions, [...] and GeneratorExit (which is not an 
error and should not normally be caught by user code).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9608
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9608] Re-phrase best way of using exceptions in doanddont.rst

2010-09-07 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

It would.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9608
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9608] Re-phrase best way of using exceptions in doanddont.rst

2010-08-20 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

Doc/howto/doanddont.rst is the source for
Python HOWTOs: Idioms and Anti-Idioms in Python
Moshe Zadka original author (added as nosy)

The gist of the patch is to clarify that using 'with' is best, not the non-with 
version that is currently called  both 'best' and 'not very good'. I agreed 
that the current version is confusing and the patch or something like it should 
be applied.

Floris: 2.6 is closed to non-critical patches. 3.3 is for patches that cannot 
be applied sooner.

--
nosy: +moshez, terry.reedy
stage:  - patch review
type: feature request - behavior
versions:  -Python 2.6, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9608
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9608] Re-phrase best way of using exceptions in doanddont.rst

2010-08-15 Thread Floris Bruynooghe

New submission from Floris Bruynooghe floris.bruynoo...@gmail.com:

The description of how to best use exceptions is slightly confusing and led me 
to believe there was an issue when using open() as a context manager.  The main 
issue is that the wording seems to suggest the example above it is the best and 
not the very last.

Attached is a patch which uses a slightly different wording which IMHO makes it 
clearer that the with-statement is the preferred method and does not introduce 
subtle bugs.

--
assignee: d...@python
components: Documentation
files: doandont.diff
keywords: patch
messages: 113949
nosy: d...@python, flub
priority: normal
severity: normal
status: open
title: Re-phrase best way of using exceptions in doanddont.rst
type: feature request
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file18538/doandont.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9608
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com