From 4428b713f952dbdaf68d1532e74f5160471e298a61a713397562bb13bd85f38e Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Thu, 6 Jun 2024 06:55:12 +0000 Subject: [PATCH 1/2] Accepting request 1178786 from home:glaubitz:branches:devel:languages:python - Update to 5.6.3 * Fixed decoding of epoch-based dates being affected by the local time zone in the C extension - from version 5.6.2 * Fixed ``__hash__()`` of the C version of the ``CBORTag`` type crashing when there's a recursive reference cycle * Fixed type annotation for the file object in ``cbor2.dump()``, ``cbor2.load()``, ``CBOREncoder`` and ``CBORDecoder`` to be ``IO[bytes]`` instead of ``BytesIO`` * Worked around a `CPython bug `_ that caused a ``SystemError`` to be raised, or even a buffer overflow to occur when decoding a long text string that contained only ASCII characters * Changed the return type annotations of ``cbor2.load()`` and ``cbor2.load()`` to return ``Any`` instead of ``object`` so as not to force users to make type casts - from version 5.6.1 * Fixed use-after-free in the decoder's C version when prematurely encountering the end of stream * Fixed the C version of the decoder improperly raising ``CBORDecodeEOF`` when decoding a text string longer than 65536 bytes - from version 5.6.0 * Added the ``cbor2`` command line tool (for ``pipx run cbor2``) * Added support for native date encoding (bschoenmaeckers) * Made the C extension mandatory when the environment variable ``CBOR2_BUILD_C_EXTENSION`` is set to ``1``. * Fixed ``SystemError`` in the C extension when decoding a ``Fractional`` with a bad number of arguments or a non-tuple value * Fixed ``SystemError`` in the C extension when the decoder object hook raises an exception * Fixed a segmentation fault when decoding invalid unicode data * Fixed infinite recursion when trying to hash a CBOR tag whose value points to the tag itself OBS-URL: https://build.opensuse.org/request/show/1178786 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-cbor2?expand=0&rev=24 --- 238.patch | 23 +++++++++++++++++++ cbor2-5.5.1.tar.gz | 3 --- cbor2-5.6.3.tar.gz | 3 +++ python-cbor2.changes | 53 ++++++++++++++++++++++++++++++++++++++++++++ python-cbor2.spec | 17 ++++++++++++-- 5 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 238.patch delete mode 100644 cbor2-5.5.1.tar.gz create mode 100644 cbor2-5.6.3.tar.gz diff --git a/238.patch b/238.patch new file mode 100644 index 0000000..bafbfd6 --- /dev/null +++ b/238.patch @@ -0,0 +1,23 @@ +From d59066471c54258a24654a4319f723eab663fabe Mon Sep 17 00:00:00 2001 +From: John Paul Adrian Glaubitz +Date: Wed, 5 Jun 2024 17:09:59 +0200 +Subject: [PATCH] Fix incorrect return type of raise_from() + +Fixes #236. +--- + source/decoder.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/source/decoder.c b/source/decoder.c +index 6fd74ce..bd7fa47 100644 +--- a/source/decoder.c ++++ b/source/decoder.c +@@ -348,7 +348,7 @@ _CBORDecoder_get_immutable(CBORDecoderObject *self, void *closure) + + // Utility functions ///////////////////////////////////////////////////////// + +-static int ++static void + raise_from(PyObject *new_exc_type, const char *message) { + // This requires the error indicator to be set + PyObject *cause; diff --git a/cbor2-5.5.1.tar.gz b/cbor2-5.5.1.tar.gz deleted file mode 100644 index 8ebaf1c..0000000 --- a/cbor2-5.5.1.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f9e192f461a9f8f6082df28c035b006d153904213dc8640bed8a72d72bbc9475 -size 94221 diff --git a/cbor2-5.6.3.tar.gz b/cbor2-5.6.3.tar.gz new file mode 100644 index 0000000..7f2d4c6 --- /dev/null +++ b/cbor2-5.6.3.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e6f0ae2751c2d333a960e0807c0611494eb1245631a167965acbc100509455d3 +size 100224 diff --git a/python-cbor2.changes b/python-cbor2.changes index 44e550d..e67fc3d 100644 --- a/python-cbor2.changes +++ b/python-cbor2.changes @@ -1,3 +1,56 @@ +------------------------------------------------------------------- +Wed Jun 5 15:47:30 UTC 2024 - John Paul Adrian Glaubitz + +- Update to 5.6.3 + * Fixed decoding of epoch-based dates being affected by the local + time zone in the C extension +- from version 5.6.2 + * Fixed ``__hash__()`` of the C version of the ``CBORTag`` type crashing + when there's a recursive reference cycle + * Fixed type annotation for the file object in ``cbor2.dump()``, ``cbor2.load()``, + ``CBOREncoder`` and ``CBORDecoder`` to be ``IO[bytes]`` instead of ``BytesIO`` + * Worked around a `CPython bug `_ + that caused a ``SystemError`` to be raised, or even a buffer overflow to occur + when decoding a long text string that contained only ASCII characters + * Changed the return type annotations of ``cbor2.load()`` and ``cbor2.load()`` + to return ``Any`` instead of ``object`` so as not to force users to make type casts +- from version 5.6.1 + * Fixed use-after-free in the decoder's C version when prematurely encountering + the end of stream + * Fixed the C version of the decoder improperly raising ``CBORDecodeEOF`` when + decoding a text string longer than 65536 bytes +- from version 5.6.0 + * Added the ``cbor2`` command line tool (for ``pipx run cbor2``) + * Added support for native date encoding (bschoenmaeckers) + * Made the C extension mandatory when the environment variable + ``CBOR2_BUILD_C_EXTENSION`` is set to ``1``. + * Fixed ``SystemError`` in the C extension when decoding a ``Fractional`` + with a bad number of arguments or a non-tuple value + * Fixed ``SystemError`` in the C extension when the decoder object hook + raises an exception + * Fixed a segmentation fault when decoding invalid unicode data + * Fixed infinite recursion when trying to hash a CBOR tag whose + value points to the tag itself + * Fixed ``MemoryError`` when maliciously constructed bytestrings or string + (declared to be absurdly large) are being decoded + * Fixed ``UnicodeDecodeError`` from failed parsing of a UTF-8 text string + not being wrapped as ``CBORDecodeValueError`` + * Fixed ``TypeError`` or ``ZeroDivisionError`` from a failed decoding of + ``Fraction`` not being wrapped as ``CBORDecodeValueError`` + * Fixed ``TypeError`` or ``ValueError`` from a failed decoding of ``UUID`` + not being wrapped as ``CBORDecodeValueError`` + * Fixed ``TypeError`` from a failed decoding of ``MIMEMessage`` not being + wrapped as ``CBORDecodeValueError`` + * Fixed ``OverflowError``, ``OSError`` or ``ValueError`` from a failed decoding + of epoch-based ``datetime`` not being wrapped as ``CBORDecodeValueError`` +- Cherry-pick upstream patch to fix build with GCC 14 + * https://github.com/agronholm/cbor2/pull/238.patch +- Add update-alternatives to Requires for post and postun +- Install cbor2 binary in %files section using %python_alternative +- Run %python_install_alternative in %post section +- Run %python_uninstall_alternative in %postun section +- Set CBOR2_BUILD_C_EXTENSION to 1 to build C extension + ------------------------------------------------------------------- Thu Dec 14 09:18:38 UTC 2023 - Petr Gajdos diff --git a/python-cbor2.spec b/python-cbor2.spec index 2eed162..c1ebbb2 100644 --- a/python-cbor2.spec +++ b/python-cbor2.spec @@ -1,7 +1,7 @@ # # spec file for package python-cbor2 # -# Copyright (c) 2023 SUSE LLC +# 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 @@ -18,12 +18,14 @@ %{?sle15_python_module_pythons} Name: python-cbor2 -Version: 5.5.1 +Version: 5.6.3 Release: 0 Summary: Pure Python CBOR (de)serializer with extensive tag support License: MIT URL: https://github.com/agronholm/cbor2 Source: https://files.pythonhosted.org/packages/source/c/cbor2/cbor2-%{version}.tar.gz +# PATCH-FIX-UPSTREAM - Fix incorrect return type of raise_from() +Patch: https://github.com/agronholm/cbor2/pull/238.patch BuildRequires: %{python_module devel} BuildRequires: %{python_module hypothesis} BuildRequires: %{python_module pip} @@ -33,6 +35,8 @@ BuildRequires: %{python_module setuptools_scm >= 6.4} BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros +Requires(post): update-alternatives +Requires(postun): update-alternatives %python_subpackages %description @@ -45,20 +49,29 @@ sed -i 's/--cov//' pyproject.toml %build export LANG=en_US.UTF8 +export CBOR2_BUILD_C_EXTENSION=1 %pyproject_wheel %install export LANG=en_US.UTF8 %pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitearch} +%python_clone -a %{buildroot}%{_bindir}/cbor2 %check export LANG=en_US.UTF8 %pytest_arch +%post +%python_install_alternative cbor2 + +%postun +%python_uninstall_alternative cbor2 + %files %{python_files} %doc README.rst %license LICENSE.txt +%python_alternative %{_bindir}/cbor2 %{python_sitearch}/*.so %{python_sitearch}/cbor2 %{python_sitearch}/cbor2*-info From 8f26a6b68256b7ee8dd8b24053f8f159415101da597cc386863f71a44f3be755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Thu, 6 Jun 2024 13:46:51 +0000 Subject: [PATCH 2/2] Accepting request 1178996 from home:glaubitz:branches:devel:languages:python - Update to 5.6.4 * Fixed compilation of C extension failing on GCC 14 * Fixed compiler warnings when building C extension - Drop patches for issues fixed upstream * https://github.com/agronholm/cbor2/pull/238.patch OBS-URL: https://build.opensuse.org/request/show/1178996 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-cbor2?expand=0&rev=25 --- 238.patch | 23 ----------------------- cbor2-5.6.3.tar.gz | 3 --- cbor2-5.6.4.tar.gz | 3 +++ python-cbor2.changes | 9 +++++++++ python-cbor2.spec | 4 +--- 5 files changed, 13 insertions(+), 29 deletions(-) delete mode 100644 238.patch delete mode 100644 cbor2-5.6.3.tar.gz create mode 100644 cbor2-5.6.4.tar.gz diff --git a/238.patch b/238.patch deleted file mode 100644 index bafbfd6..0000000 --- a/238.patch +++ /dev/null @@ -1,23 +0,0 @@ -From d59066471c54258a24654a4319f723eab663fabe Mon Sep 17 00:00:00 2001 -From: John Paul Adrian Glaubitz -Date: Wed, 5 Jun 2024 17:09:59 +0200 -Subject: [PATCH] Fix incorrect return type of raise_from() - -Fixes #236. ---- - source/decoder.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/source/decoder.c b/source/decoder.c -index 6fd74ce..bd7fa47 100644 ---- a/source/decoder.c -+++ b/source/decoder.c -@@ -348,7 +348,7 @@ _CBORDecoder_get_immutable(CBORDecoderObject *self, void *closure) - - // Utility functions ///////////////////////////////////////////////////////// - --static int -+static void - raise_from(PyObject *new_exc_type, const char *message) { - // This requires the error indicator to be set - PyObject *cause; diff --git a/cbor2-5.6.3.tar.gz b/cbor2-5.6.3.tar.gz deleted file mode 100644 index 7f2d4c6..0000000 --- a/cbor2-5.6.3.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e6f0ae2751c2d333a960e0807c0611494eb1245631a167965acbc100509455d3 -size 100224 diff --git a/cbor2-5.6.4.tar.gz b/cbor2-5.6.4.tar.gz new file mode 100644 index 0000000..3ab5165 --- /dev/null +++ b/cbor2-5.6.4.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c533c50dde86bef1c6950602054a0ffa3c376e8b0e20c7b8f5b108793f6983e +size 100865 diff --git a/python-cbor2.changes b/python-cbor2.changes index e67fc3d..a083caa 100644 --- a/python-cbor2.changes +++ b/python-cbor2.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Thu Jun 6 10:36:17 UTC 2024 - John Paul Adrian Glaubitz + +- Update to 5.6.4 + * Fixed compilation of C extension failing on GCC 14 + * Fixed compiler warnings when building C extension +- Drop patches for issues fixed upstream + * https://github.com/agronholm/cbor2/pull/238.patch + ------------------------------------------------------------------- Wed Jun 5 15:47:30 UTC 2024 - John Paul Adrian Glaubitz diff --git a/python-cbor2.spec b/python-cbor2.spec index c1ebbb2..e0e906a 100644 --- a/python-cbor2.spec +++ b/python-cbor2.spec @@ -18,14 +18,12 @@ %{?sle15_python_module_pythons} Name: python-cbor2 -Version: 5.6.3 +Version: 5.6.4 Release: 0 Summary: Pure Python CBOR (de)serializer with extensive tag support License: MIT URL: https://github.com/agronholm/cbor2 Source: https://files.pythonhosted.org/packages/source/c/cbor2/cbor2-%{version}.tar.gz -# PATCH-FIX-UPSTREAM - Fix incorrect return type of raise_from() -Patch: https://github.com/agronholm/cbor2/pull/238.patch BuildRequires: %{python_module devel} BuildRequires: %{python_module hypothesis} BuildRequires: %{python_module pip}