<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Looks like keystoneauth1.exceptions.http.__all__ includes a from_response function. Maybe add a if isinstance(..., BaseException) before appending?<div class=""><br class=""></div><div class="">Tim</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 3, 2017, at 6:48 PM, Michael Still <<a href="mailto:mikal@stillhq.com" class="">mikal@stillhq.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">So...<div class=""><br class=""></div><div class="">Our python3 tests hate [1] my exception handling for continued vendordata implementation [2].</div><div class=""><br class=""></div><div class="">Basically, it goes a bit like this -- I need to move from using requests to keystoneauth1 for external vendordata requests. This is because we're adding support for sending keystone headers with the request so that the external service can verify that it is nova talking. That bit isn't too hard.</div><div class=""><br class=""></div><div class="">However, keystoneauth1 uses different exceptions to report errors. Conveniently, it has variables which list all of the connection and http exceptions which it might raise. Inconveniently, they're listed as strings, so I have to construct a list of them like this:</div><div class=""><br class=""></div><div class=""><div class=""># NOTE(mikal): keystoneauth makes me jump through hoops to get these</div><div class=""># exceptions, which are listed as strings. Mutter.</div><div class="">KEYSTONEAUTH_EXCEPTIONS = [TypeError, ValueError]</div><div class="">for excname in ks_exceptions.connection.__all__ + ks_exceptions.http.__all__:</div><div class="">    KEYSTONEAUTH_EXCEPTIONS.append(getattr(ks_exceptions, excname))</div></div><div class=""><br class=""></div><div class="">Then when it comes time to catch exceptions from keystoneauth1, we can just do this thing:</div><div class=""><br class=""></div><div class=""><div class="">        except tuple(KEYSTONEAUTH_EXCEPTIONS) as e:</div><div class="">            LOG.warning(_LW('Error from dynamic vendordata service '</div><div class="">                            '%(service_name)s at %(url)s: %(error)s'),</div><div class="">                        {'service_name': service_name,</div><div class="">                         'url': url,</div><div class="">                         'error': e},</div><div class="">                        instance=self.instance)</div><div class="">            return {}</div></div><div class=""><br class=""></div><div class="">Which might be a bit horrible, but is nice in that if keystoneauth1 adds new connection or http exceptions, we get to catch them for free.</div><div class=""><br class=""></div><div class="">This all works and is tested. However, it causes the py3 tests to fail with this exception:</div><div class=""><br class=""></div><div class="">'TypeError: catching classes that do not inherit from BaseException is not allowed'<br class=""></div><div class=""><br class=""></div><div class="">Which is bemusing to me because I'm not very smart.</div><div class=""><br class=""></div><div class="">So, could someone smarter than me please look at [1] and tell me why I get [2] and how to not get that thing? Answers involving manually listing many exceptions will result in me making a sad face and sarcastic comment in the code, so something more elegant than that would be nice.</div><div class=""><br class=""></div><div class="">Discuss.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Michael</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">1: <a href="http://logs.openstack.org/91/416391/1/check/gate-nova-python35-db/7835df3/console.html#_2017-01-04_01_10_35_520409" class="">http://logs.openstack.org/91/416391/1/check/gate-nova-python35-db/7835df3/console.html#_2017-01-04_01_10_35_520409</a></div><div class="">2: <a href="https://review.openstack.org/#/c/415597/3/nova/api/metadata/vendordata_dynamic.py" class="">https://review.openstack.org/#/c/415597/3/nova/api/metadata/vendordata_dynamic.py</a><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature">Rackspace Australia</div>
</div></div>
__________________________________________________________________________<br class="">OpenStack Development Mailing List (not for usage questions)<br class="">Unsubscribe: <a href="mailto:OpenStack-dev-request@lists.openstack.org" class="">OpenStack-dev-request@lists.openstack.org</a>?subject:unsubscribe<br class=""><a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" class="">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br class=""></div></blockquote></div><br class=""></div></body></html>