Compare commits
No commits in common. "c10s" and "c8" have entirely different histories.
@ -1 +0,0 @@
|
||||
1
|
25
.gitignore
vendored
25
.gitignore
vendored
@ -1,24 +1 @@
|
||||
greenlet-0.3.1.tar.gz
|
||||
/greenlet-0.4.0.zip
|
||||
/greenlet-0.4.1.zip
|
||||
/greenlet-0.4.2.zip
|
||||
/greenlet-0.4.5.zip
|
||||
/greenlet-0.4.7.zip
|
||||
/greenlet-0.4.9.zip
|
||||
/0.4.11.tar.gz
|
||||
/greenlet-0.4.12.tar.gz
|
||||
/greenlet-0.4.13.tar.gz
|
||||
/greenlet-0.4.14.tar.gz
|
||||
/greenlet-0.4.16.tar.gz
|
||||
/greenlet-0.4.17.tar.gz
|
||||
/greenlet-1.1.0.tar.gz
|
||||
/greenlet-1.1.1.tar.gz
|
||||
/greenlet-1.1.2.tar.gz
|
||||
/greenlet-1.1.3.tar.gz
|
||||
/greenlet-2.0.2.tar.gz
|
||||
/greenlet-3.0.0a1.tar.gz
|
||||
/greenlet-3.0.0rc1.tar.gz
|
||||
/greenlet-3.0.0.tar.gz
|
||||
/greenlet-3.0.1.tar.gz
|
||||
/greenlet-3.0.2.tar.gz
|
||||
/greenlet-3.0.3.tar.gz
|
||||
SOURCES/greenlet-0.4.13.tar.gz
|
||||
|
1
.python-greenlet.metadata
Normal file
1
.python-greenlet.metadata
Normal file
@ -0,0 +1 @@
|
||||
105fcc7bae9e388e4b9a05b7c431ad2a637a0f75 SOURCES/greenlet-0.4.13.tar.gz
|
26
SOURCES/0001-Don-t-clobber-r2-register-on-ppc64el.patch
Normal file
26
SOURCES/0001-Don-t-clobber-r2-register-on-ppc64el.patch
Normal file
@ -0,0 +1,26 @@
|
||||
From d32e64abf2443ada592f6a1e5d74bee35db0f221 Mon Sep 17 00:00:00 2001
|
||||
From: "Laszlo Boszormenyi (GCS)" <gcs@debian.org>
|
||||
Date: Sat, 9 Sep 2017 07:57:16 +0000
|
||||
Subject: [PATCH] Don't clobber 'r2' register on ppc64el
|
||||
|
||||
It was invalid even before, now GCC 7 no longer accept this.
|
||||
---
|
||||
platform/switch_ppc64_linux.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/platform/switch_ppc64_linux.h b/platform/switch_ppc64_linux.h
|
||||
index 0f20756..cd7d748 100644
|
||||
--- a/platform/switch_ppc64_linux.h
|
||||
+++ b/platform/switch_ppc64_linux.h
|
||||
@@ -56,7 +56,7 @@
|
||||
#define ALTIVEC_REGS
|
||||
#endif
|
||||
|
||||
-#define REGS_TO_SAVE "r2", "r14", "r15", "r16", "r17", "r18", "r19", "r20", \
|
||||
+#define REGS_TO_SAVE "r14", "r15", "r16", "r17", "r18", "r19", "r20", \
|
||||
"r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r31", \
|
||||
"fr14", "fr15", "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", \
|
||||
"fr22", "fr23", "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", \
|
||||
--
|
||||
2.15.1
|
||||
|
@ -1,17 +1,21 @@
|
||||
%if 0%{?rhel} > 7
|
||||
# Disable python2 build by default
|
||||
%bcond_with python2
|
||||
%else
|
||||
%bcond_without python2
|
||||
%endif
|
||||
|
||||
%global modname greenlet
|
||||
|
||||
Name: python-%{modname}
|
||||
Version: 3.0.3
|
||||
Release: 5%{?dist}
|
||||
Version: 0.4.13
|
||||
Release: 4%{?dist}
|
||||
Summary: Lightweight in-process concurrent programming
|
||||
License: MIT AND PSF-2.0
|
||||
License: MIT
|
||||
URL: https://github.com/python-greenlet/greenlet
|
||||
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++
|
||||
# https://github.com/python-greenlet/greenlet/pull/120
|
||||
Patch0001: 0001-Don-t-clobber-r2-register-on-ppc64el.patch
|
||||
|
||||
%global _description \
|
||||
The greenlet package is a spin-off of Stackless, a version of CPython\
|
||||
@ -21,18 +25,43 @@ and are synchronized with data exchanges on "channels".
|
||||
|
||||
%description %{_description}
|
||||
|
||||
%if %{with python2}
|
||||
%package -n python2-%{modname}
|
||||
Summary: %{summary}
|
||||
%{?python_provide:%python_provide python2-%{modname}}
|
||||
BuildRequires: python2-devel
|
||||
BuildRequires: python2-setuptools
|
||||
|
||||
%description -n python2-%{modname} %{_description}
|
||||
|
||||
Python 2 version.
|
||||
%endif # with python2
|
||||
|
||||
%package -n python3-%{modname}
|
||||
Summary: %{summary}
|
||||
%{?python_provide:%python_provide python3-%{modname}}
|
||||
BuildRequires: python3-devel
|
||||
# For tests
|
||||
BuildRequires: python3-psutil
|
||||
BuildRequires: python3-setuptools
|
||||
|
||||
%description -n python3-%{modname} %{_description}
|
||||
|
||||
Python 3 version.
|
||||
|
||||
%if %{with python2}
|
||||
%package -n python2-%{modname}-devel
|
||||
Summary: C development headers for python2-%{modname}
|
||||
%{?python_provide:%python_provide python2-%{modname}-devel}
|
||||
Requires: python2-%{modname}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
|
||||
|
||||
%description -n python2-%{modname}-devel
|
||||
%{summary}.
|
||||
|
||||
Python 2 version.
|
||||
%endif # with python2
|
||||
|
||||
%package -n python3-%{modname}-devel
|
||||
Summary: C development headers for python3-%{modname}
|
||||
%{?python_provide:%python_provide python3-%{modname}-devel}
|
||||
Requires: python3-%{modname}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
|
||||
|
||||
%description -n python3-%{modname}-devel
|
||||
@ -43,157 +72,51 @@ Python 3 version.
|
||||
%prep
|
||||
%autosetup -n %{modname}-%{version} -p1
|
||||
|
||||
%generate_buildrequires
|
||||
%pyproject_buildrequires
|
||||
|
||||
%build
|
||||
%pyproject_wheel
|
||||
%if %{with python2}
|
||||
%py2_build
|
||||
%endif # with python2
|
||||
%py3_build
|
||||
|
||||
%install
|
||||
%pyproject_install
|
||||
%pyproject_save_files %{modname}
|
||||
|
||||
%if %{with python2}
|
||||
%py2_install
|
||||
%endif # with python2
|
||||
%py3_install
|
||||
|
||||
%check
|
||||
cd /
|
||||
PYTHONPATH="%{buildroot}%{python3_sitearch}" \
|
||||
%{python3} -m unittest discover -v \
|
||||
-s "%{buildroot}%{python3_sitearch}/greenlet/tests" \
|
||||
-t "%{buildroot}%{python3_sitearch}"
|
||||
%if %{with python2}
|
||||
%{__python2} setup.py test
|
||||
%endif # with python2
|
||||
%{__python3} setup.py test
|
||||
|
||||
%files -n python3-%{modname} -f %{pyproject_files}
|
||||
%doc AUTHORS README.rst
|
||||
%if %{with python2}
|
||||
%files -n python2-%{modname}
|
||||
%license LICENSE LICENSE.PSF
|
||||
%doc AUTHORS NEWS README.rst
|
||||
%{python2_sitearch}/%{modname}-*.egg-info
|
||||
%{python2_sitearch}/%{modname}.so
|
||||
|
||||
%files -n python2-%{modname}-devel
|
||||
%{_includedir}/python%{python2_version}*/%{modname}/
|
||||
%endif # with python2
|
||||
|
||||
%files -n python3-%{modname}
|
||||
%license LICENSE LICENSE.PSF
|
||||
%doc AUTHORS NEWS README.rst
|
||||
%{python3_sitearch}/%{modname}-*.egg-info
|
||||
%{python3_sitearch}/%{modname}*.so
|
||||
|
||||
%files -n python3-greenlet-devel
|
||||
%{_includedir}/python%{python3_version}*/%{modname}/
|
||||
|
||||
%changelog
|
||||
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 3.0.3-5
|
||||
- Bump release for October 2024 mass rebuild:
|
||||
Resolves: RHEL-64018
|
||||
* Thu Nov 07 2019 Brian C. Lane <bcl@redhat.com> - 0.4.13-4
|
||||
- Add gating tests
|
||||
Resolves: rhbz#1682344
|
||||
|
||||
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 3.0.3-4
|
||||
- Bump release for June 2024 mass rebuild
|
||||
|
||||
* 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
|
||||
|
||||
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.0-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
|
||||
|
||||
* Thu Jun 03 2021 Python Maint <python-maint@redhat.com> - 1.1.0-2
|
||||
- Rebuilt for Python 3.10
|
||||
|
||||
* Mon May 10 2021 Nils Philippsen <nils@tiptoe.de> - 1.1.0-1
|
||||
- Update to 1.1.0
|
||||
|
||||
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.17-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||
|
||||
* Sat Oct 31 2020 Kevin Fenzi <kevin@scrye.com> - 0.4.17-1
|
||||
- Update to 0.4.17. Fixes bug #1881455
|
||||
|
||||
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.16-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||
|
||||
* Sat Jun 06 2020 Orion Poplawski <orion@nwra.com> - 0.4.16-1
|
||||
- Update to 0.4.16
|
||||
|
||||
* Sat May 23 2020 Miro Hrončok <mhroncok@redhat.com> - 0.4.14-8
|
||||
- Rebuilt for Python 3.9
|
||||
|
||||
* Thu May 21 2020 Miro Hrončok <mhroncok@redhat.com> - 0.4.14-7
|
||||
- Fix Python 3.9 build
|
||||
|
||||
* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.14-6
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||
|
||||
* Thu Sep 26 2019 Miro Hrončok <mhroncok@redhat.com> - 0.4.14-5
|
||||
- Subpackages python2-greenlet, python2-greenlet-devel have been removed
|
||||
See https://fedoraproject.org/wiki/Changes/Mass_Python_2_Package_Removal
|
||||
|
||||
* Fri Aug 16 2019 Miro Hrončok <mhroncok@redhat.com> - 0.4.14-4
|
||||
- Rebuilt for Python 3.8
|
||||
|
||||
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.14-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
||||
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.14-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
|
||||
|
||||
* Wed Jul 18 2018 Kevin Fenzi <kevin@scrye.com> - 0.4.14-1
|
||||
- Update to 0.4.14.
|
||||
- Drop upstreamed/no longer needed patches.
|
||||
|
||||
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.13-5
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
|
||||
|
||||
* Tue Jul 03 2018 Miro Hrončok <mhroncok@redhat.com> - 0.4.13-4
|
||||
- Add fix for Python 3.7
|
||||
|
||||
* Sat Jun 16 2018 Miro Hrončok <mhroncok@redhat.com> - 0.4.13-3
|
||||
- Rebuilt for Python 3.7
|
||||
* Wed Jul 18 2018 Charalampos Stratakis <cstratak@redhat.com> - 0.4.13-3
|
||||
- Conditionalize the python2 subpackage
|
||||
|
||||
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.13-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
|
5
ci.fmf
5
ci.fmf
@ -1,5 +0,0 @@
|
||||
/keylime-e2e:
|
||||
plan:
|
||||
import:
|
||||
url: https://github.com/RedHat-SP-Security/keylime-plans.git
|
||||
name: /generic/minimal-e2e
|
@ -1,6 +0,0 @@
|
||||
--- !Policy
|
||||
product_versions:
|
||||
- rhel-10
|
||||
decision_context: osci_compose_gate
|
||||
rules:
|
||||
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
|
@ -1,293 +0,0 @@
|
||||
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
|
Loading…
Reference in New Issue
Block a user