Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53028 > unrolled thread
| Started by | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| First post | 2013-08-26 20:16 -0700 |
| Last post | 2013-08-26 20:16 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Missing something on exception handling in Python 3 Ethan Furman <ethan@stoneleaf.us> - 2013-08-26 20:16 -0700
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2013-08-26 20:16 -0700 |
| Subject | Re: Missing something on exception handling in Python 3 |
| Message-ID | <mailman.254.1377574592.19984.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web