Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53028
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ethan@stoneleaf.us> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'subject:Python': 0.06; '%s"': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'try:': 0.09; '~ethan~': 0.09; 'chained': 0.16; 'oserror': 0.16; 'python3.': 0.16; 'received:69.41.248': 0.16; 'subject:exception': 0.16; 'subject:handling': 0.16; 'exception': 0.16; 'index': 0.16; 'wrote:': 0.18; 'thanks.': 0.20; 'header:User-Agent:1': 0.23; '2.x': 0.24; 'skip': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'raise': 0.29; 'except': 0.35; 'something': 0.35; 'there': 0.35; 'raising': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:173': 0.61; "you're": 0.61; 'skip:w 30': 0.69; 'received:gateway02.websitewelcome.com': 0.91 |
| Date | Mon, 26 Aug 2013 20:16:00 -0700 |
| From | Ethan Furman <ethan@stoneleaf.us> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Missing something on exception handling in Python 3 |
| References | <CANc-5Uztbwz5cYk6K8vdLdjaFSPOO4qmROvPoUqfGFCnW6JVqA@mail.gmail.com> <521C0B62.1030004@mrabarnett.plus.com> <CANc-5Uyi_EXHLHbe9v7U8iNL00iCO8T-JMnaiAUmcB5sz-qd_A@mail.gmail.com> |
| In-Reply-To | <CANc-5Uyi_EXHLHbe9v7U8iNL00iCO8T-JMnaiAUmcB5sz-qd_A@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-AntiAbuse | This header was added to track abuse, please include it with any abuse report |
| X-AntiAbuse | Primary Hostname - gator3304.hostgator.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - stoneleaf.us |
| X-BWhitelist | no |
| X-Source | |
| X-Source-Args | |
| X-Source-Dir | |
| X-Source-Sender | ([173.12.184.233]) [173.12.184.233]:42123 |
| X-Source-Auth | ethan+stoneleaf.us |
| X-Email-Count | 1 |
| X-Source-Cap | dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20= |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.254.1377574592.19984.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1377574592 news.xs4all.nl 15889 [2001:888:2000:d::a6]:55760 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:53028 |
Show key headers only | View raw
On 08/26/2013 07:49 PM, Skip Montanaro wrote:
>> Do this:
>>
>> raise LockFailed("Failed to create %s" % self.path) from None
>
> Thanks. Is there some construct which will work in 2.x and 3.x?
Something like this (untested):
exc = None
try:
write_pid_to_lockfile(somefile)
except OSError as exc:
exc = sys.exc_info()[0] # not sure of index
if exc:
if conditions_i_can_handle:
do_other_stuff...
else:
raise LockFailed("Failed to create %s" % self.path)
Since you're raising outside the try...except block you won't see the chained exception in Python3.
--
~Ethan~
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Missing something on exception handling in Python 3 Ethan Furman <ethan@stoneleaf.us> - 2013-08-26 20:16 -0700
csiph-web