[openstack-dev] [nova] contextlib.nested and Python3 failing

Kevin L. Mitchell kevin.mitchell at rackspace.com
Fri Aug 21 15:39:34 UTC 2015


On Wed, 2015-08-19 at 16:51 -0700, Sylvain Bauza wrote:
> I was writing some tests so I added a contextlib.nested to a checked 
> TestCase [1]. Unfortunately, contextlib.nested is no longer available in 
> Python3 and there is no clear solution on how to provide a compatible 
> import for both python2 and python3:
>   - either providing a python3 compatible behaviour by using 
> contextlib.ExitStack but that class is not available in Python 2
>   - or provide contextlib2 for python2 (and thus adding it to the 
> requirements)

Actually, there should no longer be a need to use contextlib.nested.
We've explicitly dropped Python 2.6 compatibility, which means we're
expecting compatibility with Python 2.7+ only, and as of Python 2.7, the
'with' statement supports accepting multiple 'as' clauses.  The
contextlib.nested tool was really only necessary to work around that
functionality being missing in Python 2.6, and has been deprecated as of
Python 2.7 because it's no longer necessary.
-- 
Kevin L. Mitchell <kevin.mitchell at rackspace.com>
Rackspace




More information about the OpenStack-dev mailing list