Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53024
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| 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; 'output': 0.05; 'subject:Python': 0.06; '%s"': 0.09; 'exception,': 0.09; 'skip:/ 10': 0.09; 'suppress': 0.09; 'try:': 0.09; 'python': 0.11; '(apologies': 0.16; 'dislike': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'oserror': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:exception': 0.16; 'subject:handling': 0.16; 'exception': 0.16; 'wrote:': 0.18; '(not': 0.18; 'typing': 0.19; 'appears': 0.22; 'header:User-Agent:1': 0.23; 'skip': 0.24; 'looks': 0.24; 'handling': 0.26; 'permission': 0.26; 'this:': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'raise': 0.29; "i'm": 0.30; 'code': 0.31; "skip:' 10": 0.31; '"",': 0.31; '>>>>': 0.31; 'indentation': 0.31; 'file': 0.32; 'another': 0.32; '(most': 0.33; 'except': 0.35; 'received:84': 0.35; 'level': 0.37; 'growing': 0.38; 'skip:o 20': 0.38; 'gmail': 0.38; 'to:addr :python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'how': 0.40; 'lower': 0.61; 'header:Reply-To:1': 0.67; 'skip:w 30': 0.69; 'reply-to:no real name:2**0': 0.71; 'reply-to:addr:python.org': 0.84 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=ZMDuxxLb c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=0kkAYlmtguIA:10 a=vYuu8KyStN0A:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=-xzeBAf6dKEA:10 a=b7HOTFdILELxzaKf5HkA:9 a=wPNLvfGTeEIA:10 |
| X-AUTH | mrabarnett:2500 |
| Date | Tue, 27 Aug 2013 03:13:54 +0100 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 |
| 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> |
| In-Reply-To | <CANc-5Uztbwz5cYk6K8vdLdjaFSPOO4qmROvPoUqfGFCnW6JVqA@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | python-list@python.org |
| 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.251.1377569630.19984.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1377569630 news.xs4all.nl 15910 [2001:888:2000:d::a6]:36906 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:53024 |
Show key headers only | View raw
On 27/08/2013 02:48, Skip Montanaro wrote:
> I have code in the pylockfile package that looks roughly like this
> (apologies for the indentation - I'm growing to dislike Gmail for
> typing code fragments):
>
> try:
> write_pid_to_lockfile(somefile)
> except OSError as exc:
> if conditions_i_can_handle:
> do_other_stuff...
> else:
> raise LockFailed("Failed to create %s" % self.path)
>
> Thinking I would just get the final exception (not the one I caught
> originally), I was surprised to see this output on my screen:
>
>>>> lock.acquire()
> Traceback (most recent call last):
> File "lockfile/pidlockfile.py", line 80, in acquire
> write_pid_to_pidfile(self.path)
> File "lockfile/pidlockfile.py", line 163, in write_pid_to_pidfile
> pidfile_fd = os.open(pidfile_path, open_flags, open_mode)
> OSError: [Errno 13] Permission denied: '/tmp/skip/lock'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "lockfile/pidlockfile.py", line 94, in acquire
> raise LockFailed("failed to create %s" % self.path)
> lockfile.LockFailed: failed to create /tmp/skip/lock
>
> When I rung the same code with Python 2.7, I get the exception output
> I anticipate:
>
>>>> lock.acquire()
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "lockfile/pidlockfile.py", line 94, in acquire
> raise LockFailed("failed to create %s" % self.path)
> LockFailed: failed to create /tmp/skip/lock
>
> It appears exception handling changed in Python 3. How do I suppress
> the lower level OSError?
>
Do this:
raise LockFailed("Failed to create %s" % self.path) from None
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Missing something on exception handling in Python 3 MRAB <python@mrabarnett.plus.com> - 2013-08-27 03:13 +0100
csiph-web