Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #109172 > unrolled thread

Re: Handling exceptions with Py2 and Py3

Started byRandom832 <random832@fastmail.com>
First post2016-05-27 09:42 -0400
Last post2016-05-27 09:42 -0400
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.


Contents

  Re: Handling exceptions with Py2 and Py3 Random832 <random832@fastmail.com> - 2016-05-27 09:42 -0400

#109172 — Re: Handling exceptions with Py2 and Py3

FromRandom832 <random832@fastmail.com>
Date2016-05-27 09:42 -0400
SubjectRe: Handling exceptions with Py2 and Py3
Message-ID<mailman.21.1464356582.2277.python-list@python.org>
On Fri, May 27, 2016, at 09:18, Ben Finney wrote:
>     try:
>         short_routine()
>     except ConnectionRefusedError as exc:
>         handle_connection_refused(exc)
>     except OSError as exc:
>         if exc.errno == errno.ECONNREFUSED:
>             handle_connection_refused(exc)

But ConnectionRefusedError inherits from OSError and has errno =
ECONNREFUSED. So you can simply only have the second except block here,
and ignore the fact that Python 3 has a class hierarchy of error types.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web