Hello community,

here is the log from the commit of package python-contextlib2 for 
openSUSE:Leap:15.2 checked in at 2020-03-29 14:55:54
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/python-contextlib2 (Old)
 and      /work/SRC/openSUSE:Leap:15.2/.python-contextlib2.new.3160 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-contextlib2"

Sun Mar 29 14:55:54 2020 rev:11 rq:789166 version:0.6.0

Changes:
--------
--- /work/SRC/openSUSE:Leap:15.2/python-contextlib2/python-contextlib2.changes  
2020-01-15 15:47:59.023410305 +0100
+++ 
/work/SRC/openSUSE:Leap:15.2/.python-contextlib2.new.3160/python-contextlib2.changes
        2020-03-29 14:55:55.251168564 +0200
@@ -1,0 +2,23 @@
+Tue Sep 24 11:44:26 UTC 2019 - Tomáš Chvátal <tchva...@suse.com>
+
+- Update to 0.6.0:
+  * Various minor fixes and metadata updates
+  * Add nullcontext
+  * Add AbstractContextManager
+
+-------------------------------------------------------------------
+Tue May 22 11:05:09 UTC 2018 - tchva...@suse.com
+
+- Do not run the tests twice for no reason
+
+-------------------------------------------------------------------
+Tue May 22 10:56:10 UTC 2018 - mc...@suse.com
+
+- Clean the SPEC, enable tests
+
+-------------------------------------------------------------------
+Thu Aug 24 13:34:54 UTC 2017 - jmate...@suse.com
+
+- singlespec auto-conversion
+
+-------------------------------------------------------------------
@@ -54,0 +78 @@
+

Old:
----
  contextlib2-0.5.5.tar.gz

New:
----
  contextlib2-0.6.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-contextlib2.spec ++++++
--- /var/tmp/diff_new_pack.0LTcp2/_old  2020-03-29 14:55:55.611168845 +0200
+++ /var/tmp/diff_new_pack.0LTcp2/_new  2020-03-29 14:55:55.619168851 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-contextlib2
 #
-# Copyright (c) 2017 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
 # Copyright (c) 2014 LISA GmbH, Bingen, Germany.
 #
 # All modifications and additions to the file contributed by third parties
@@ -13,27 +13,25 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
-
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
+#
 
-%bcond_without test
 
+%{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-contextlib2
-Version:        0.5.5
+Version:        0.6.0
 Release:        0
-License:        Python-2.0
 Summary:        Backports and enhancements for the contextlib module
-Url:            http://contextlib2.readthedocs.org
+License:        Python-2.0
 Group:          Development/Languages/Python
+URL:            http://contextlib2.readthedocs.org
 Source:         
https://files.pythonhosted.org/packages/source/c/contextlib2/contextlib2-%{version}.tar.gz
-BuildRequires:  python-devel
-BuildRequires:  python-setuptools
-%if %{with test}
-BuildRequires:  python-unittest2
-%endif
-Provides:       python2-contextlib2 = %{version}
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+BuildRequires:  %{python_module setuptools}
+BuildRequires:  %{python_module unittest2}
+BuildRequires:  fdupes
+BuildRequires:  python-rpm-macros
 BuildArch:      noarch
+%python_subpackages
 
 %description
 contextlib2 is a backport of the standard library's contextlib module to
@@ -46,19 +44,18 @@
 %setup -q -n contextlib2-%{version}
 
 %build
-python setup.py build
+%python_build
 
 %install
-python setup.py install --prefix=%{_prefix} --root=%{buildroot}
+%python_install
+%python_expand %fdupes %{buildroot}%{$python_sitelib}
 
-%if %{with test}
 %check
-python2 test_contextlib2.py
-%endif
+%python_expand PYTHONPATH=%{buildroot}%{$python_sitelib} $python 
test_contextlib2.py
 
-%files
-%defattr(-,root,root,-)
-%doc README.rst NEWS.rst LICENSE.txt
+%files %{python_files}
+%license LICENSE.txt
+%doc README.rst NEWS.rst
 %{python_sitelib}/*
 
 %changelog

++++++ contextlib2-0.5.5.tar.gz -> contextlib2-0.6.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/contextlib2-0.5.5/NEWS.rst 
new/contextlib2-0.6.0/NEWS.rst
--- old/contextlib2-0.5.5/NEWS.rst      2017-04-25 05:51:01.000000000 +0200
+++ new/contextlib2-0.6.0/NEWS.rst      2019-09-21 15:16:23.000000000 +0200
@@ -1,6 +1,13 @@
 Release History
 ---------------
 
+0.6.0 (Unreleased)
+^^^^^^^^^^^^^^^^^^
+
+* Issue `#16 <https://github.com/jazzband/contextlib2/issues/16>`__:
+  Backport `AbstractContextManager` from Python 3.6 and `nullcontext`
+  from Python 3.7 (patch by John Vandenberg)
+
 0.5.5 (2017-04-25)
 ^^^^^^^^^^^^^^^^^^
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/contextlib2-0.5.5/PKG-INFO 
new/contextlib2-0.6.0/PKG-INFO
--- old/contextlib2-0.5.5/PKG-INFO      2017-04-25 05:51:27.000000000 +0200
+++ new/contextlib2-0.6.0/PKG-INFO      2019-09-21 15:16:50.000000000 +0200
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
 Name: contextlib2
-Version: 0.5.5
+Version: 0.6.0
 Summary: Backports and enhancements for the contextlib module
 Home-page: http://contextlib2.readthedocs.org
 Author: Nick Coghlan
@@ -47,29 +47,22 @@
         
         Versions currently tested in both tox and Travis CI are:
         
-        * CPython 2.6
         * CPython 2.7
         * CPython 3.4
         * CPython 3.5
         * CPython 3.6
-        * CPython 3.7 (CPython development branch)
+        * CPython 3.7
         * PyPy
-        
-        Versions currently tested only in tox are:
-        
         * PyPy3
         
-        This is due to an exception chaining compatibility bug that was fixed 
in
-        the PyPy3 5.5 alpha release, while the version on Travis CI (as of 
April 2017)
-        is still the older PyPy3 2.4.0 release.
-        
 Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: License :: OSI Approved :: Python Software Foundation License
 Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/contextlib2-0.5.5/README.rst 
new/contextlib2-0.6.0/README.rst
--- old/contextlib2-0.5.5/README.rst    2017-04-25 05:51:01.000000000 +0200
+++ new/contextlib2-0.6.0/README.rst    2019-09-21 15:16:23.000000000 +0200
@@ -39,18 +39,10 @@
 
 Versions currently tested in both tox and Travis CI are:
 
-* CPython 2.6
 * CPython 2.7
 * CPython 3.4
 * CPython 3.5
 * CPython 3.6
-* CPython 3.7 (CPython development branch)
+* CPython 3.7
 * PyPy
-
-Versions currently tested only in tox are:
-
 * PyPy3
-
-This is due to an exception chaining compatibility bug that was fixed in
-the PyPy3 5.5 alpha release, while the version on Travis CI (as of April 2017)
-is still the older PyPy3 2.4.0 release.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/contextlib2-0.5.5/VERSION.txt 
new/contextlib2-0.6.0/VERSION.txt
--- old/contextlib2-0.5.5/VERSION.txt   2017-04-25 05:51:01.000000000 +0200
+++ new/contextlib2-0.6.0/VERSION.txt   2019-09-21 15:16:23.000000000 +0200
@@ -1 +1 @@
-0.5.5
+0.6.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/contextlib2-0.5.5/contextlib2.egg-info/PKG-INFO 
new/contextlib2-0.6.0/contextlib2.egg-info/PKG-INFO
--- old/contextlib2-0.5.5/contextlib2.egg-info/PKG-INFO 2017-04-25 
05:51:27.000000000 +0200
+++ new/contextlib2-0.6.0/contextlib2.egg-info/PKG-INFO 2019-09-21 
15:16:50.000000000 +0200
@@ -1,6 +1,6 @@
-Metadata-Version: 1.1
+Metadata-Version: 1.2
 Name: contextlib2
-Version: 0.5.5
+Version: 0.6.0
 Summary: Backports and enhancements for the contextlib module
 Home-page: http://contextlib2.readthedocs.org
 Author: Nick Coghlan
@@ -47,29 +47,22 @@
         
         Versions currently tested in both tox and Travis CI are:
         
-        * CPython 2.6
         * CPython 2.7
         * CPython 3.4
         * CPython 3.5
         * CPython 3.6
-        * CPython 3.7 (CPython development branch)
+        * CPython 3.7
         * PyPy
-        
-        Versions currently tested only in tox are:
-        
         * PyPy3
         
-        This is due to an exception chaining compatibility bug that was fixed 
in
-        the PyPy3 5.5 alpha release, while the version on Travis CI (as of 
April 2017)
-        is still the older PyPy3 2.4.0 release.
-        
 Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: License :: OSI Approved :: Python Software Foundation License
 Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/contextlib2-0.5.5/contextlib2.py 
new/contextlib2-0.6.0/contextlib2.py
--- old/contextlib2-0.5.5/contextlib2.py        2017-04-25 05:51:01.000000000 
+0200
+++ new/contextlib2-0.6.0/contextlib2.py        2019-09-21 15:16:23.000000000 
+0200
@@ -1,18 +1,77 @@
 """contextlib2 - backports and enhancements to the contextlib module"""
 
+import abc
 import sys
 import warnings
 from collections import deque
 from functools import wraps
 
-__all__ = ["contextmanager", "closing", "ContextDecorator", "ExitStack",
+__all__ = ["contextmanager", "closing", "nullcontext",
+           "AbstractContextManager",
+           "ContextDecorator", "ExitStack",
            "redirect_stdout", "redirect_stderr", "suppress"]
 
 # Backwards compatibility
 __all__ += ["ContextStack"]
 
+
+# Backport abc.ABC
+if sys.version_info[:2] >= (3, 4):
+    _abc_ABC = abc.ABC
+else:
+    _abc_ABC = abc.ABCMeta('ABC', (object,), {'__slots__': ()})
+
+
+# Backport classic class MRO
+def _classic_mro(C, result):
+    if C in result:
+        return
+    result.append(C)
+    for B in C.__bases__:
+        _classic_mro(B, result)
+    return result
+
+
+# Backport _collections_abc._check_methods
+def _check_methods(C, *methods):
+    try:
+        mro = C.__mro__
+    except AttributeError:
+        mro = tuple(_classic_mro(C, []))
+
+    for method in methods:
+        for B in mro:
+            if method in B.__dict__:
+                if B.__dict__[method] is None:
+                    return NotImplemented
+                break
+        else:
+            return NotImplemented
+    return True
+
+
+class AbstractContextManager(_abc_ABC):
+    """An abstract base class for context managers."""
+
+    def __enter__(self):
+        """Return `self` upon entering the runtime context."""
+        return self
+
+    @abc.abstractmethod
+    def __exit__(self, exc_type, exc_value, traceback):
+        """Raise any exception triggered within the runtime context."""
+        return None
+
+    @classmethod
+    def __subclasshook__(cls, C):
+        """Check whether subclass is considered a subclass of this ABC."""
+        if cls is AbstractContextManager:
+            return _check_methods(C, "__enter__", "__exit__")
+        return NotImplemented
+
+
 class ContextDecorator(object):
-    "A base class or mixin that enables context managers to work as 
decorators."
+    """A base class or mixin that enables context managers to work as 
decorators."""
 
     def refresh_cm(self):
         """Returns the context manager used to actually wrap the call to the
@@ -176,8 +235,10 @@
     """
     def __init__(self, thing):
         self.thing = thing
+
     def __enter__(self):
         return self.thing
+
     def __exit__(self, *exc_info):
         self.thing.close()
 
@@ -289,7 +350,7 @@
     # but use exec to avoid SyntaxError in Python 3
     def _reraise_with_existing_context(exc_details):
         exc_type, exc_value, exc_tb = exc_details
-        exec ("raise exc_type, exc_value, exc_tb")
+        exec("raise exc_type, exc_value, exc_tb")
 
 # Handle old-style classes if they exist
 try:
@@ -302,8 +363,9 @@
     def _get_type(obj):
         obj_type = type(obj)
         if obj_type is InstanceType:
-            return obj.__class__ # Old-style class
-        return obj_type # New-style class
+            return obj.__class__  # Old-style class
+        return obj_type  # New-style class
+
 
 # Inspired by discussions on http://bugs.python.org/issue13585
 class ExitStack(object):
@@ -417,6 +479,7 @@
             _reraise_with_existing_context(exc_details)
         return received_exc and suppressed_exc
 
+
 # Preserve backwards compatibility
 class ContextStack(ExitStack):
     """Backwards compatibility alias for ExitStack"""
@@ -434,3 +497,22 @@
 
     def preserve(self):
         return self.pop_all()
+
+
+class nullcontext(AbstractContextManager):
+    """Context manager that does no additional processing.
+    Used as a stand-in for a normal context manager, when a particular
+    block of code is only sometimes used with a normal context manager:
+    cm = optional_cm if condition else nullcontext()
+    with cm:
+        # Perform operation, using optional_cm if condition is True
+    """
+
+    def __init__(self, enter_result=None):
+        self.enter_result = enter_result
+
+    def __enter__(self):
+        return self.enter_result
+
+    def __exit__(self, *excinfo):
+        pass
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/contextlib2-0.5.5/docs/index.rst 
new/contextlib2-0.6.0/docs/index.rst
--- old/contextlib2-0.5.5/docs/index.rst        2017-04-25 05:51:01.000000000 
+0200
+++ new/contextlib2-0.6.0/docs/index.rst        2019-09-21 15:16:23.000000000 
+0200
@@ -21,11 +21,13 @@
 Additions Relative to the Standard Library
 ------------------------------------------
 
-This module is primarily a backport of the Python 3.5 version of
-:mod:`contextlib` to earlier releases. However, it is also a proving ground
-for new features not yet part of the standard library.
+This module is primarily a backport of the Python 3.6 version of
+:mod:`contextlib` to earlier releases.  It includes `nullcontext` from
+Python 3.7, however it does not yet provide async context management
+support from Python 3.7.
 
-There are currently no such features in the module.
+However, it is also a proving ground for new features not yet part of the
+standard library.  There are currently no such features in the module.
 
 Refer to the :mod:`contextlib` documentation for details of which
 versions of Python 3 introduce the various APIs provided in this module.
@@ -36,6 +38,19 @@
 
 Functions and classes provided:
 
+
+.. class:: AbstractContextManager
+
+   An :term:`abstract base class` for classes that implement
+   :meth:`object.__enter__` and :meth:`object.__exit__`. A default
+   implementation for :meth:`object.__enter__` is provided which returns
+   ``self`` while :meth:`object.__exit__` is an abstract method which by 
default
+   returns ``None``.
+
+   .. versionadded:: 0.6.0
+      Part of the standard library in Python 3.6 and later
+
+
 .. decorator:: contextmanager
 
    This function is a :term:`decorator` that can be used to define a factory
@@ -110,6 +125,39 @@
    ``page.close()`` will be called when the :keyword:`with` block is exited.
 
 
+.. function:: nullcontext(enter_result=None)
+
+   Return a context manager that returns *enter_result* from ``__enter__``, but
+   otherwise does nothing. It is intended to be used as a stand-in for an
+   optional context manager, for example::
+
+      def myfunction(arg, ignore_exceptions=False):
+          if ignore_exceptions:
+              # Use suppress to ignore all exceptions.
+              cm = contextlib.suppress(Exception)
+          else:
+              # Do not ignore any exceptions, cm has no effect.
+              cm = contextlib.nullcontext()
+          with cm:
+              # Do something
+
+   An example using *enter_result*::
+
+      def process_file(file_or_path):
+          if isinstance(file_or_path, str):
+              # If string, open file
+              cm = open(file_or_path)
+          else:
+              # Caller is responsible for closing file
+              cm = nullcontext(file_or_path)
+
+          with cm as file:
+              # Perform processing on the file
+
+   .. versionadded:: 0.6.0
+      Part of the standard library in Python 3.7 and later
+
+
 .. function:: suppress(*exceptions)
 
    Return a context manager that suppresses any of the specified exceptions
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/contextlib2-0.5.5/setup.py 
new/contextlib2-0.6.0/setup.py
--- old/contextlib2-0.5.5/setup.py      2017-04-25 05:51:01.000000000 +0200
+++ new/contextlib2-0.6.0/setup.py      2019-09-21 15:16:23.000000000 +0200
@@ -7,6 +7,7 @@
 setup(
     name='contextlib2',
     version=open('VERSION.txt').read().strip(),
+    python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
     py_modules=['contextlib2'],
     license='PSF License',
     description='Backports and enhancements for the contextlib module',
@@ -19,12 +20,12 @@
         'License :: OSI Approved :: Python Software Foundation License',
         # These are the Python versions tested, it may work on others
         'Programming Language :: Python :: 2',
-        'Programming Language :: Python :: 2.6',
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
+        'Programming Language :: Python :: 3.7',
     ],
 
 )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/contextlib2-0.5.5/test_contextlib2.py 
new/contextlib2-0.6.0/test_contextlib2.py
--- old/contextlib2-0.5.5/test_contextlib2.py   2017-04-25 05:51:01.000000000 
+0200
+++ new/contextlib2-0.6.0/test_contextlib2.py   2019-09-21 15:16:23.000000000 
+0200
@@ -15,6 +15,58 @@
 requires_docstrings = unittest.skipIf(sys.flags.optimize >= 2,
                                       "Test requires docstrings")
 
+
+class TestAbstractContextManager(unittest.TestCase):
+
+    def test_enter(self):
+        class DefaultEnter(AbstractContextManager):
+            def __exit__(self, *args):
+                super().__exit__(*args)
+
+        manager = DefaultEnter()
+        self.assertIs(manager.__enter__(), manager)
+
+    def test_exit_is_abstract(self):
+        class MissingExit(AbstractContextManager):
+            pass
+
+        with self.assertRaises(TypeError):
+            MissingExit()
+
+    def test_structural_subclassing(self):
+        # New style classes used here
+        class ManagerFromScratch(object):
+            def __enter__(self):
+                return self
+            def __exit__(self, exc_type, exc_value, traceback):
+                return None
+
+        self.assertTrue(issubclass(ManagerFromScratch, AbstractContextManager))
+
+        class DefaultEnter(AbstractContextManager):
+            def __exit__(self, *args):
+                super().__exit__(*args)
+
+        self.assertTrue(issubclass(DefaultEnter, AbstractContextManager))
+
+    if sys.version_info[:2] <= (3, 0):
+        def test_structural_subclassing_classic(self):
+            # Old style classes used here
+            class ManagerFromScratch:
+                def __enter__(self):
+                    return self
+                def __exit__(self, exc_type, exc_value, traceback):
+                    return None
+
+            self.assertTrue(issubclass(ManagerFromScratch, 
AbstractContextManager))
+
+            class DefaultEnter(AbstractContextManager):
+                def __exit__(self, *args):
+                    super().__exit__(*args)
+
+            self.assertTrue(issubclass(DefaultEnter, AbstractContextManager))
+
+
 class ContextManagerTestCase(unittest.TestCase):
 
     def test_contextmanager_plain(self):
@@ -911,6 +963,16 @@
             # This shouldn't raise an exception.
             stack.enter_context(suppress())
 
+
+class NullcontextTestCase(unittest.TestCase):
+    def test_nullcontext(self):
+        class C:
+            pass
+        c = C()
+        with nullcontext(c) as c_in:
+            self.assertIs(c_in, c)
+
+
 if __name__ == "__main__":
     import unittest
     unittest.main()


Reply via email to