Looks like keystoneauth1.exceptions.http.__all__ includes a from_response 
function. Maybe add a if isinstance(..., BaseException) before appending?

Tim

> On Jan 3, 2017, at 6:48 PM, Michael Still <[email protected]> wrote:
> 
> So...
> 
> Our python3 tests hate [1] my exception handling for continued vendordata 
> implementation [2].
> 
> 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.
> 
> 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:
> 
> # NOTE(mikal): keystoneauth makes me jump through hoops to get these
> # exceptions, which are listed as strings. Mutter.
> KEYSTONEAUTH_EXCEPTIONS = [TypeError, ValueError]
> for excname in ks_exceptions.connection.__all__ + ks_exceptions.http.__all__:
>     KEYSTONEAUTH_EXCEPTIONS.append(getattr(ks_exceptions, excname))
> 
> Then when it comes time to catch exceptions from keystoneauth1, we can just 
> do this thing:
> 
>         except tuple(KEYSTONEAUTH_EXCEPTIONS) as e:
>             LOG.warning(_LW('Error from dynamic vendordata service '
>                             '%(service_name)s at %(url)s: %(error)s'),
>                         {'service_name': service_name,
>                          'url': url,
>                          'error': e},
>                         instance=self.instance)
>             return {}
> 
> 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.
> 
> This all works and is tested. However, it causes the py3 tests to fail with 
> this exception:
> 
> 'TypeError: catching classes that do not inherit from BaseException is not 
> allowed'
> 
> Which is bemusing to me because I'm not very smart.
> 
> 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.
> 
> Discuss.
> 
> Thanks,
> Michael
> 
> 
> 1: 
> http://logs.openstack.org/91/416391/1/check/gate-nova-python35-db/7835df3/console.html#_2017-01-04_01_10_35_520409
>  
> <http://logs.openstack.org/91/416391/1/check/gate-nova-python35-db/7835df3/console.html#_2017-01-04_01_10_35_520409>
> 2: 
> https://review.openstack.org/#/c/415597/3/nova/api/metadata/vendordata_dynamic.py
>  
> <https://review.openstack.org/#/c/415597/3/nova/api/metadata/vendordata_dynamic.py>
> 
> -- 
> Rackspace Australia
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: [email protected]?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: [email protected]?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to