Change in vdsm[master]: suppress for python2
phoracek at redhat.com
phoracek at redhat.com
Wed Mar 30 15:43:02 UTC 2016
Petr Horáček has posted comments on this change.
Change subject: suppress for python2
......................................................................
Patch Set 11: Verified+1
common/contextlib_test.py passed OK.
[root at centos7-vdsmbox ~]# python2
Python 2.7.5 (default, Nov 20 2015, 02:00:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from vdsm.compat import suppress
>>> print(suppress.__doc__)
Python >= 3.4 suppress context manager.
https://docs.python.org/3/library/contextlib.html#contextlib.suppress
>>> with suppress(OSError):
... raise OSError()
...
[root at centos7-vdsmbox ~]# PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/site-packages/ python3
Python 3.4.3 (default, Jan 26 2016, 02:25:35)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from vdsm.compat import suppress
>>> print(suppress.__doc__)
Context manager to suppress specified exceptions
After the exception is suppressed, execution proceeds with the next
statement following the with statement.
with suppress(FileNotFoundError):
os.remove(somefile)
# Execution still resumes here if the file was already removed
>>> with suppress(OSError):
... raise OSError()
...
--
To view, visit https://gerrit.ovirt.org/55065
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I76d5b0658435e59701ac4d845827e86026085c07
Gerrit-PatchSet: 11
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Edward Haas <edwardh at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Petr Horáček <phoracek at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
Gerrit-HasComments: No
More information about the vdsm-patches
mailing list