Compare commits

...

No commits in common. 'c9' and 'c10-beta' have entirely different histories.
c9 ... c10-beta

2
.gitignore vendored

@ -1 +1 @@
SOURCES/greenlet-1.1.2.tar.gz SOURCES/greenlet-3.0.3.tar.gz

@ -1 +1 @@
959222fc19fffb3849dd50f08aa5fa59ae7e659f SOURCES/greenlet-1.1.2.tar.gz 93cdb28a276c3711fe75dac96d9cb97ed0b5c0d7 SOURCES/greenlet-3.0.3.tar.gz

@ -0,0 +1,293 @@
diff --git a/src/greenlet/tests/leakcheck.py b/src/greenlet/tests/leakcheck.py
index a5152fb..ebe12e5 100644
--- a/src/greenlet/tests/leakcheck.py
+++ b/src/greenlet/tests/leakcheck.py
@@ -30,39 +30,7 @@ import gc
from functools import wraps
import unittest
-
-import objgraph
-
-# graphviz 0.18 (Nov 7 2021), available only on Python 3.6 and newer,
-# has added type hints (sigh). It wants to use ``typing.Literal`` for
-# some stuff, but that's only available on Python 3.9+. If that's not
-# found, it creates a ``unittest.mock.MagicMock`` object and annotates
-# with that. These are GC'able objects, and doing almost *anything*
-# with them results in an explosion of objects. For example, trying to
-# compare them for equality creates new objects. This causes our
-# leakchecks to fail, with reports like:
-#
-# greenlet.tests.leakcheck.LeakCheckError: refcount increased by [337, 1333, 343, 430, 530, 643, 769]
-# _Call 1820 +546
-# dict 4094 +76
-# MagicProxy 585 +73
-# tuple 2693 +66
-# _CallList 24 +3
-# weakref 1441 +1
-# function 5996 +1
-# type 736 +1
-# cell 592 +1
-# MagicMock 8 +1
-#
-# To avoid this, we *could* filter this type of object out early. In
-# principle it could leak, but we don't use mocks in greenlet, so it
-# doesn't leak from us. However, a further issue is that ``MagicMock``
-# objects have subobjects that are also GC'able, like ``_Call``, and
-# those create new mocks of their own too. So we'd have to filter them
-# as well, and they're not public. That's OK, we can workaround the
-# problem by being very careful to never compare by equality or other
-# user-defined operators, only using object identity or other builtin
-# functions.
+# Edited for Fedora to avoid missing dependency
RUNNING_ON_GITHUB_ACTIONS = os.environ.get('GITHUB_ACTIONS')
RUNNING_ON_TRAVIS = os.environ.get('TRAVIS') or RUNNING_ON_GITHUB_ACTIONS
@@ -74,53 +42,15 @@ SKIP_FAILING_LEAKCHECKS = os.environ.get('GREENLET_SKIP_FAILING_LEAKCHECKS')
ONLY_FAILING_LEAKCHECKS = os.environ.get('GREENLET_ONLY_FAILING_LEAKCHECKS')
def ignores_leakcheck(func):
- """
- Ignore the given object during leakchecks.
-
- Can be applied to a method, in which case the method will run, but
- will not be subject to leak checks.
-
- If applied to a class, the entire class will be skipped during leakchecks. This
- is intended to be used for classes that are very slow and cause problems such as
- test timeouts; typically it will be used for classes that are subclasses of a base
- class and specify variants of behaviour (such as pool sizes).
- """
- func.ignore_leakcheck = True
return func
def fails_leakcheck(func):
- """
- Mark that the function is known to leak.
- """
- func.fails_leakcheck = True
- if SKIP_FAILING_LEAKCHECKS:
- func = unittest.skip("Skipping known failures")(func)
return func
class LeakCheckError(AssertionError):
pass
-if hasattr(sys, 'getobjects'):
- # In a Python build with ``--with-trace-refs``, make objgraph
- # trace *all* the objects, not just those that are tracked by the
- # GC
- class _MockGC(object):
- def get_objects(self):
- return sys.getobjects(0) # pylint:disable=no-member
- def __getattr__(self, name):
- return getattr(gc, name)
- objgraph.gc = _MockGC()
- fails_strict_leakcheck = fails_leakcheck
-else:
- def fails_strict_leakcheck(func):
- """
- Decorator for a function that is known to fail when running
- strict (``sys.getobjects()``) leakchecks.
-
- This type of leakcheck finds all objects, even those, such as
- strings, which are not tracked by the garbage collector.
- """
- return func
+fails_strict_leakcheck = fails_leakcheck
class ignores_types_in_strict_leakcheck(object):
def __init__(self, types):
@@ -129,191 +59,5 @@ class ignores_types_in_strict_leakcheck(object):
func.leakcheck_ignore_types = self.types
return func
-class _RefCountChecker(object):
-
- # Some builtin things that we ignore
- # XXX: Those things were ignored by gevent, but they're important here,
- # presumably.
- IGNORED_TYPES = () #(tuple, dict, types.FrameType, types.TracebackType)
-
- def __init__(self, testcase, function):
- self.testcase = testcase
- self.function = function
- self.deltas = []
- self.peak_stats = {}
- self.ignored_types = ()
-
- # The very first time we are called, we have already been
- # self.setUp() by the test runner, so we don't need to do it again.
- self.needs_setUp = False
-
- def _include_object_p(self, obj):
- # pylint:disable=too-many-return-statements
- #
- # See the comment block at the top. We must be careful to
- # avoid invoking user-defined operations.
- if obj is self:
- return False
- kind = type(obj)
- # ``self._include_object_p == obj`` returns NotImplemented
- # for non-function objects, which causes the interpreter
- # to try to reverse the order of arguments...which leads
- # to the explosion of mock objects. We don't want that, so we implement
- # the check manually.
- if kind == type(self._include_object_p):
- try:
- # pylint:disable=not-callable
- exact_method_equals = self._include_object_p.__eq__(obj)
- except AttributeError:
- # Python 2.7 methods may only have __cmp__, and that raises a
- # TypeError for non-method arguments
- # pylint:disable=no-member
- exact_method_equals = self._include_object_p.__cmp__(obj) == 0
-
- if exact_method_equals is not NotImplemented and exact_method_equals:
- return False
-
- # Similarly, we need to check identity in our __dict__ to avoid mock explosions.
- for x in self.__dict__.values():
- if obj is x:
- return False
-
-
- if kind in self.ignored_types or kind in self.IGNORED_TYPES:
- return False
-
- return True
-
- def _growth(self):
- return objgraph.growth(limit=None, peak_stats=self.peak_stats,
- filter=self._include_object_p)
-
- def _report_diff(self, growth):
- if not growth:
- return "<Unable to calculate growth>"
-
- lines = []
- width = max(len(name) for name, _, _ in growth)
- for name, count, delta in growth:
- lines.append('%-*s%9d %+9d' % (width, name, count, delta))
-
- diff = '\n'.join(lines)
- return diff
-
-
- def _run_test(self, args, kwargs):
- gc_enabled = gc.isenabled()
- gc.disable()
-
- if self.needs_setUp:
- self.testcase.setUp()
- self.testcase.skipTearDown = False
- try:
- self.function(self.testcase, *args, **kwargs)
- finally:
- self.testcase.tearDown()
- self.testcase.doCleanups()
- self.testcase.skipTearDown = True
- self.needs_setUp = True
- if gc_enabled:
- gc.enable()
-
- def _growth_after(self):
- # Grab post snapshot
- # pylint:disable=no-member
- if 'urlparse' in sys.modules:
- sys.modules['urlparse'].clear_cache()
- if 'urllib.parse' in sys.modules:
- sys.modules['urllib.parse'].clear_cache()
-
- return self._growth()
-
- def _check_deltas(self, growth):
- # Return false when we have decided there is no leak,
- # true if we should keep looping, raises an assertion
- # if we have decided there is a leak.
-
- deltas = self.deltas
- if not deltas:
- # We haven't run yet, no data, keep looping
- return True
-
- if gc.garbage:
- raise LeakCheckError("Generated uncollectable garbage %r" % (gc.garbage,))
-
-
- # the following configurations are classified as "no leak"
- # [0, 0]
- # [x, 0, 0]
- # [... a, b, c, d] where a+b+c+d = 0
- #
- # the following configurations are classified as "leak"
- # [... z, z, z] where z > 0
-
- if deltas[-2:] == [0, 0] and len(deltas) in (2, 3):
- return False
-
- if deltas[-3:] == [0, 0, 0]:
- return False
-
- if len(deltas) >= 4 and sum(deltas[-4:]) == 0:
- return False
-
- if len(deltas) >= 3 and deltas[-1] > 0 and deltas[-1] == deltas[-2] and deltas[-2] == deltas[-3]:
- diff = self._report_diff(growth)
- raise LeakCheckError('refcount increased by %r\n%s' % (deltas, diff))
-
- # OK, we don't know for sure yet. Let's search for more
- if sum(deltas[-3:]) <= 0 or sum(deltas[-4:]) <= 0 or deltas[-4:].count(0) >= 2:
- # this is suspicious, so give a few more runs
- limit = 11
- else:
- limit = 7
- if len(deltas) >= limit:
- raise LeakCheckError('refcount increased by %r\n%s'
- % (deltas,
- self._report_diff(growth)))
-
- # We couldn't decide yet, keep going
- return True
-
- def __call__(self, args, kwargs):
- for _ in range(3):
- gc.collect()
-
- expect_failure = getattr(self.function, 'fails_leakcheck', False)
- if expect_failure:
- self.testcase.expect_greenlet_leak = True
- self.ignored_types = getattr(self.function, "leakcheck_ignore_types", ())
-
- # Capture state before; the incremental will be
- # updated by each call to _growth_after
- growth = self._growth()
-
- try:
- while self._check_deltas(growth):
- self._run_test(args, kwargs)
-
- growth = self._growth_after()
-
- self.deltas.append(sum((stat[2] for stat in growth)))
- except LeakCheckError:
- if not expect_failure:
- raise
- else:
- if expect_failure:
- raise LeakCheckError("Expected %s to leak but it did not." % (self.function,))
-
def wrap_refcount(method):
- if getattr(method, 'ignore_leakcheck', False) or SKIP_LEAKCHECKS:
- return method
-
- @wraps(method)
- def wrapper(self, *args, **kwargs): # pylint:disable=too-many-branches
- if getattr(self, 'ignore_leakcheck', False):
- raise unittest.SkipTest("This class ignored during leakchecks")
- if ONLY_FAILING_LEAKCHECKS and not getattr(method, 'fails_leakcheck', False):
- raise unittest.SkipTest("Only running tests that fail leakchecks.")
- return _RefCountChecker(self, method)(args, kwargs)
-
- return wrapper
+ return method

@ -1,12 +1,16 @@
%global modname greenlet %global modname greenlet
Name: python-%{modname} Name: python-%{modname}
Version: 1.1.2 Version: 3.0.3
Release: 4%{?dist} Release: 4%{?dist}
Summary: Lightweight in-process concurrent programming Summary: Lightweight in-process concurrent programming
License: MIT License: MIT AND PSF-2.0
URL: https://github.com/python-greenlet/greenlet URL: https://github.com/python-greenlet/greenlet
Source0: %{url}/archive/%{version}/%{modname}-%{version}.tar.gz Source0: %{url}/archive/%{version}/%{modname}-%{version}.tar.gz
# Skip leak checking to avoid a missing dependency, `objgraph`
Patch: skip-leak-checks.patch
BuildRequires: gcc-c++ BuildRequires: gcc-c++
%global _description \ %global _description \
@ -19,9 +23,9 @@ and are synchronized with data exchanges on "channels".
%package -n python3-%{modname} %package -n python3-%{modname}
Summary: %{summary} Summary: %{summary}
%{?python_provide:%python_provide python3-%{modname}}
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: python3-setuptools # For tests
BuildRequires: python3-psutil
%description -n python3-%{modname} %{_description} %description -n python3-%{modname} %{_description}
@ -29,7 +33,6 @@ Python 3 version.
%package -n python3-%{modname}-devel %package -n python3-%{modname}-devel
Summary: C development headers for python3-%{modname} Summary: C development headers for python3-%{modname}
%{?python_provide:%python_provide python3-%{modname}-devel}
Requires: python3-%{modname}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} Requires: python3-%{modname}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
%description -n python3-%{modname}-devel %description -n python3-%{modname}-devel
@ -40,39 +43,106 @@ Python 3 version.
%prep %prep
%autosetup -n %{modname}-%{version} -p1 %autosetup -n %{modname}-%{version} -p1
%generate_buildrequires
%pyproject_buildrequires
%build %build
%py3_build %pyproject_wheel
%install %install
%py3_install %pyproject_install
%pyproject_save_files %{modname}
%check %check
PYTHONPATH="%{buildroot}%{python3_sitearch}" %{python3} -m unittest discover greenlet.tests cd /
PYTHONPATH="%{buildroot}%{python3_sitearch}" \
%{python3} -m unittest discover -v \
-s "%{buildroot}%{python3_sitearch}/greenlet/tests" \
-t "%{buildroot}%{python3_sitearch}"
%files -n python3-%{modname} %files -n python3-%{modname} -f %{pyproject_files}
%license LICENSE LICENSE.PSF
%doc AUTHORS README.rst %doc AUTHORS README.rst
%{python3_sitearch}/%{modname}-*.egg-info
%{python3_sitearch}/%{modname}
%files -n python3-greenlet-devel %files -n python3-greenlet-devel
%{_includedir}/python%{python3_version}*/%{modname}/ %{_includedir}/python%{python3_version}*/%{modname}/
%changelog %changelog
* Tue May 09 2023 Brian C. Lane <bcl@redhat.com> - 1.1.2-4 * Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 3.0.3-4
- Bump release for move of -devel subpackage to CRB - Bump release for June 2024 mass rebuild
Resolves: rhbz#2149497
* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 3.0.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Sat Jan 13 2024 Terje Rosten <terje.rosten@ntnu.no> - 3.0.3-1
- 3.0.3
* Mon Dec 11 2023 Terje Rosten <terje.rosten@ntnu.no> - 3.0.2-1
- 3.0.2
* Sat Nov 25 2023 Terje Rosten <terje.rosten@ntnu.no> - 3.0.1-1
- 3.0.1
* Sat Oct 14 2023 Terje Rosten <terje.rosten@ntnu.no> - 3.0.0-1
- 3.0.0
* Wed Sep 06 2023 Carl George <carlwgeorge@fedoraproject.org> - 3.0.0~rc1-1
- Update to version 3.0.0rc1
- Convert to pyproject macros
* Sun Aug 13 2023 Orion Poplawski <orion@nwra.com> - 3.0.0~a1-1
- Update to 3.0.0a1
* Sat Aug 05 2023 Ondřej Budai <ondrej@budai.cz> - 2.0.2-3
- SPDX migration
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Wed Jun 14 2023 Petr Viktorin <pviktori@redhat.com> - 2.0.2-1
- Update to upstream version 2.0.2
- Update patch for Python 3.12 compatibility
- Skip leak checks for now
* Tue Jun 13 2023 Python Maint <python-maint@redhat.com> - 1.1.3-3
- Rebuilt for Python 3.12
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Fri Oct 14 2022 Lumír Balhar <lbalhar@redhat.com> - 1.1.3-1
- Update to 1.1.3
* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 1.1.2-4
- Rebuilt for Python 3.11
* Wed Jun 01 2022 Miro Hrončok <mhroncok@redhat.com> - 1.1.2-3
- Python 3.11 support
- Fixes: rhbz#2040186
* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Thu Sep 30 2021 Kevin Fenzi <kevin@scrye.com> - 1.1.2-1
- Update to 1.1.2. Fixes rhbz#2008848
* Sat Aug 07 2021 Kevin Fenzi <kevin@scrye.com> - 1.1.1-1
- Update to 1.1.1.
- Fixes rhbz#1990901
* Wed Jun 15 2022 Sergio Correia <scorreia@redhat.com> - 1.1.2-3 * Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.0-3
- Add python-greenlet to RHEL-9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
Resolves: rhbz#2084555
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 0.4.17-4 * Thu Jun 03 2021 Python Maint <python-maint@redhat.com> - 1.1.0-2
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags - Rebuilt for Python 3.10
Related: rhbz#1991688
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 0.4.17-3 * Mon May 10 2021 Nils Philippsen <nils@tiptoe.de> - 1.1.0-1
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 - Update to 1.1.0
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.17-2 * Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.17-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

Loading…
Cancel
Save