Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53023
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.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 | <skip.montanaro@gmail.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:pobox.com': 0.16; 'from:addr:skip': 0.16; 'oserror': 0.16; 'subject:exception': 0.16; 'subject:handling': 0.16; 'exception': 0.16; 'sender:addr:gmail.com': 0.17; '(not': 0.18; 'typing': 0.19; '>>>': 0.22; 'appears': 0.22; 'skip': 0.24; 'looks': 0.24; 'handling': 0.26; 'permission': 0.26; 'skip:" 20': 0.27; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; "skip:' 10": 0.31; '"",': 0.31; 'indentation': 0.31; 'file': 0.32; 'another': 0.32; '(most': 0.33; 'except': 0.35; 'received:google.com': 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; 'skip:w 30': 0.69 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=O/bwX29H6Yp+kGCv9QpVHr58QFzmoU8zzd33Qoj5DAM=; b=Aq4bhYzIAL6HBkzYec0hDwOZJwHgKdTqxV6oL3Dj9uVmsRfsDTTe4v4nzIuebH6Sie mLD5fUjaXEpijzVt/DQ0S/RTxoY755I0ouH/7mJPNf73sA8wd9bfwe4OEglLg/HoZIjm OP2J8gDddt46HazD4+DybC/mTnPASAKYOwPvPyDtEuj3INe140AxO2bQ3ZBVIYjuSGko IDHhDIa9kn0S5jGqmUGimYtVyUVx8get3l/14w8VX+uYXKde8byxIe0uYmk1t/P0ACnT Vv00b6mmLIG98VCTVHBeDiy1W5wYVBH4W/CpThDZe+Cgf94ZdTiWjlWIq47VX0Rk2GMN Fb3g== |
| MIME-Version | 1.0 |
| X-Received | by 10.52.180.229 with SMTP id dr5mr14657101vdc.20.1377568083674; Mon, 26 Aug 2013 18:48:03 -0700 (PDT) |
| Sender | skip.montanaro@gmail.com |
| Date | Mon, 26 Aug 2013 20:48:03 -0500 |
| X-Google-Sender-Auth | 40UGgpALTyKFIobTuFqlruZ3224 |
| Subject | Missing something on exception handling in Python 3 |
| From | Skip Montanaro <skip@pobox.com> |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.250.1377568091.19984.python-list@python.org> (permalink) |
| Lines | 47 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1377568091 news.xs4all.nl 15907 [2001:888:2000:d::a6]:33638 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:53023 |
Show key headers only | View raw
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?
Thx,
Skip
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Missing something on exception handling in Python 3 Skip Montanaro <skip@pobox.com> - 2013-08-26 20:48 -0500
csiph-web