- Cherry-pick patch from Fedora to fix testsuite with Python 3.13

* test_pickle_exception-even-harder-location-stripping.patch

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-tblib?expand=0&rev=20
This commit is contained in:
Matej Cepl 2024-09-09 20:52:16 +00:00 committed by Git OBS Bridge
commit 7226568526
9 changed files with 365 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

3
_multibuild Normal file
View File

@ -0,0 +1,3 @@
<multibuild>
<package>test</package>
</multibuild>

View File

@ -0,0 +1,44 @@
From 66e14cdd101e4214cca6acca8f48b9abe4f75729 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ionel=20Cristian=20M=C4=83rie=C8=99?= <contact@ionelmc.ro>
Date: Fri, 15 Dec 2023 16:52:07 +0200
Subject: [PATCH] More aggressive location stripping. Ref #74.
---
tests/test_pickle_exception.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Index: tblib-3.0.0/tests/test_pickle_exception.py
===================================================================
--- tblib-3.0.0.orig/tests/test_pickle_exception.py
+++ tblib-3.0.0/tests/test_pickle_exception.py
@@ -29,6 +29,10 @@ class CustomError(Exception):
pass
+def strip_locations(tb_text):
+ return tb_text.replace(' ~~^~~\n', '').replace(' ^^^^^^^^^^^^^^^^^\n', '')
+
+
@pytest.mark.parametrize('protocol', [None, *list(range(1, pickle.HIGHEST_PROTOCOL + 1))])
@pytest.mark.parametrize('how', ['global', 'instance', 'class'])
def test_install(clear_dispatch_table, how, protocol):
@@ -58,8 +62,8 @@ def test_install(clear_dispatch_table, h
else:
raise AssertionError
- expected_format_exception = ''.join(format_exception(type(exc), exc, exc.__traceback__))
- print(expected_format_exception)
+ expected_format_exception = strip_locations(''.join(format_exception(type(exc), exc, exc.__traceback__)))
+
# Populate Exception.__dict__, which is used in some cases
exc.x = 1
exc.__cause__.x = 2
@@ -88,7 +92,7 @@ def test_install(clear_dispatch_table, h
if has_python311:
assert exc.__notes__ == ['note 1', 'note 2']
- assert expected_format_exception == ''.join(format_exception(type(exc), exc, exc.__traceback__))
+ assert expected_format_exception == strip_locations(''.join(format_exception(type(exc), exc, exc.__traceback__)))
@tblib.pickling_support.install

87
python-tblib.changes Normal file
View File

@ -0,0 +1,87 @@
-------------------------------------------------------------------
Mon Sep 9 12:30:08 UTC 2024 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Cherry-pick patch from Fedora to fix testsuite with Python 3.13
* test_pickle_exception-even-harder-location-stripping.patch
-------------------------------------------------------------------
Fri May 31 22:34:24 UTC 2024 - Matej Cepl <mcepl@cepl.eu>
- Clean up SPEC file.
-------------------------------------------------------------------
Fri May 17 09:22:14 UTC 2024 - Markéta Machová <mmachova@suse.com>
- Update to 3.0.0
* Removed support for legacy Pythons (2.7 up to 3.7) and added Pythons
3.11 and 3.12 in the test grid.
* Added support for __context__, __suppress_context__ and __notes__.
* Added the get_locals argument to tblib.pickling_support.install(),
tblib.Traceback and tblib.Frame.
- Add vendore-reraise-from-six.patch to get rid of six
- Add more-aggressive-location-stripping.patch to fix test failure
- Standardize multibuild
-------------------------------------------------------------------
Fri Jun 9 11:45:42 UTC 2023 - ecsos <ecsos@opensuse.org>
- Add %{?sle15_python_module_pythons}
-------------------------------------------------------------------
Wed Sep 16 21:26:47 UTC 2020 - Dirk Mueller <dmueller@suse.com>
- update to 1.7.0:
* Add more attributes to ``Frame`` and ``Code`` objects for pytest compatibility.
-------------------------------------------------------------------
Sun Dec 15 16:02:49 UTC 2019 - Stefan Brüns <stefan.bruens@rwth-aachen.de>
- Move the Twisted test out of the main package to avoid the
Twisted dependency chain.
-------------------------------------------------------------------
Sun Dec 15 15:34:21 UTC 2019 - Stefan Brüns <stefan.bruens@rwth-aachen.de>
- version update to 1.6.0
* When pickling an Exception, also pickle its traceback and the Exception
chain (raise ... from ...). Contributed by Guido Imperiale in #53.
- version update to 1.5.0
* Added support for Python 3.8. Contributed by Victor Stinner in #42.
* Removed support for end of life Python 3.4.
* Few CI improvements and fixes.
-------------------------------------------------------------------
Mon May 6 07:56:48 UTC 2019 - pgajdos@suse.com
- version update to 1.4.0
* Remove support for end of life Python 3.3.
* Fixed tests for Python 3.7. Contributed by Elliott Sales de Andrade in
`#36 <https://github.com/ionelmc/python-tblib/issues/36>`_.
* Fixed compatibility issue with Twised (``twisted.python.failure.Failure``
expected a ``co_code`` attribute).
- deleted patches
- 0001-Patch-tests-against-Python-3.7.patch (upstreamed)
-------------------------------------------------------------------
Sun Mar 3 10:29:39 UTC 2019 - John Vandenberg <jayvdb@gmail.com>
- Remove bcond_with test preventing the tests from running,
and fix the %check
- Remove unnecessary dependency on tox, flake8 and 9 other deps
- Add 0001-Patch-tests-against-Python-3.7.patch to workaround
Python 3.7 test failure.
-------------------------------------------------------------------
Tue Dec 4 12:55:02 UTC 2018 - Matej Cepl <mcepl@suse.com>
- Remove superfluous devel dependency for noarch package
-------------------------------------------------------------------
Mon Mar 19 19:55:11 UTC 2018 - sebix+novell.com@sebix.at
- Use %license macro for license.
-------------------------------------------------------------------
Mon Aug 14 00:28:19 UTC 2017 - toddrme2178@gmail.com
- Initial version

99
python-tblib.spec Normal file
View File

@ -0,0 +1,99 @@
#
# spec file for package python-tblib
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -%{flavor}
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif
%{?sle15_python_module_pythons}
Name: python-tblib%{?psuffix}
Version: 3.0.0
Release: 0
Summary: Traceback serialization library
License: BSD-2-Clause
Group: Development/Languages/Python
URL: https://github.com/ionelmc/python-tblib
Source: https://files.pythonhosted.org/packages/source/t/tblib/tblib-%{version}.tar.gz
# PATCH-FIX-UPSTREAM https://github.com/ionelmc/python-tblib/pull/77 vendore reraise() from six
Patch0: vendore-reraise-from-six.patch
# PATCH-FIX-UPSTREAM https://github.com/ionelmc/python-tblib/issues/74 More aggressive location stripping. Ref #74.
Patch1: more-aggressive-location-stripping.patch
# PATCH-FIX-FEDORA https://src.fedoraproject.org/rpms/python-tblib/blob/rawhide/f/0001-test_pickle_exception-even-harder-location-stripping.patch
Patch2: test_pickle_exception-even-harder-location-stripping.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildArch: noarch
%if %{with test}
BuildRequires: %{python_module Twisted}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module tblib == %{version}}
%endif
%python_subpackages
%description
Traceback serialization library.
It allows you to:
* Pickle tracebacks and raise exceptions with pickled tracebacks in
different processes. This allows better error handling when running
code over multiple processes (imagine multiprocessing, billiard,
futures, celery etc).
* Create traceback objects from strings (the ``from_string`` method).
*No pickling is used*.
* Serialize tracebacks to/from plain dicts (the ``from_dict`` and
``to_dict`` methods). *No pickling is used*.
* Raise the tracebacks created from the aforementioned sources.
Again, note that using the pickle support is completely optional. You
are solely responsible for security problems should you decide to use
the pickle support.
%prep
%autosetup -p1 -n tblib-%{version}
%build
%pyproject_wheel
%install
%if !%{with test}
%pyproject_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%endif
%check
%if %{with test}
%pytest
%endif
%if !%{with test}
%files %{python_files}
%doc AUTHORS.rst CHANGELOG.rst README.rst
%license LICENSE
%{python_sitelib}/tblib
%{python_sitelib}/tblib-%{version}*-info
%endif
%changelog

3
tblib-3.0.0.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:93622790a0a29e04f0346458face1e144dc4d32f493714c6c3dff82a4adb77e6
size 30616

View File

@ -0,0 +1,42 @@
From 11329603da1f9600e29bbd8f2c2a704ae0062e49 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Tue, 18 Jun 2024 12:19:02 -0700
Subject: [PATCH] test_pickle_exception: even harder location stripping. Ref
#74.
With Python 3.13, we need to strip even harder, because we get
location lines with differing amounts of tildes and up carets in
them, e.g.:
~~^~~~~
and:
^^^^^^^
Let's ditch the regex and instead go line-by-line with a pretty
loose match for anything that looks like a location line.
Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
tests/test_pickle_exception.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tests/test_pickle_exception.py b/tests/test_pickle_exception.py
index 53a9dce..afe0d69 100644
--- a/tests/test_pickle_exception.py
+++ b/tests/test_pickle_exception.py
@@ -30,7 +30,9 @@ class CustomError(Exception):
def strip_locations(tb_text):
- return tb_text.replace(' ~~^~~\n', '').replace(' ^^^^^^^^^^^^^^^^^\n', '')
+ lines = tb_text.splitlines()
+ lines = [line for line in lines if '~~^~~' not in line and '^^^^' not in line]
+ return '\n'.join(lines)
@pytest.mark.parametrize('protocol', [None, *list(range(1, pickle.HIGHEST_PROTOCOL + 1))])
--
2.45.2

View File

@ -0,0 +1,63 @@
From 9f6f864f7de6ce6640bab6d962f00b956da75361 Mon Sep 17 00:00:00 2001
From: Alexandre Detiste <alexandre.detiste@gmail.com>
Date: Wed, 1 May 2024 13:43:53 +0200
Subject: [PATCH] vendore reraise() from six
---
ci/requirements.txt | 1 -
setup.py | 2 +-
src/tblib/decorators.py | 14 ++++++++++++--
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/ci/requirements.txt b/ci/requirements.txt
index a1708f4..b4f1852 100644
--- a/ci/requirements.txt
+++ b/ci/requirements.txt
@@ -1,6 +1,5 @@
virtualenv>=16.6.0
pip>=19.1.1
setuptools>=18.0.1
-six>=1.14.0
tox
twine
diff --git a/setup.py b/setup.py
index c5364a1..c09d4c3 100755
--- a/setup.py
+++ b/setup.py
@@ -64,7 +64,7 @@ def read(*names, **kwargs):
],
python_requires='>=3.8',
install_requires=[
- # eg: "aspectlib==1.1.1", "six>=1.7",
+ # eg: "aspectlib==1.1.1",
],
extras_require={
# eg:
diff --git a/src/tblib/decorators.py b/src/tblib/decorators.py
index 38d0675..a1ace45 100644
--- a/src/tblib/decorators.py
+++ b/src/tblib/decorators.py
@@ -1,11 +1,21 @@
import sys
from functools import wraps
-from six import reraise
-
from . import Traceback
+def reraise(tp, value, tb=None):
+ try:
+ if value is None:
+ value = tp()
+ if value.__traceback__ is not tb:
+ raise value.with_traceback(tb)
+ raise value
+ finally:
+ value = None
+ tb = None
+
+
class Error:
def __init__(self, exc_type, exc_value, traceback):
self.exc_type = exc_type