From f27db54f1d41892c31186d8048054955d4489461 Mon Sep 17 00:00:00 2001 From: zhangliangpengkun Date: Sat, 7 Jan 2023 10:38:54 +0800 Subject: [PATCH] backport fixed-passing-self-instead-of-stream Signed-off-by: zhangliangpengkun --- ...fixed-passing-self-instead-of-stream.patch | 42 +++++++++++++++++++ python-construct.spec | 8 +++- 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 python-construct-2.10.68-fixed-passing-self-instead-of-stream.patch diff --git a/python-construct-2.10.68-fixed-passing-self-instead-of-stream.patch b/python-construct-2.10.68-fixed-passing-self-instead-of-stream.patch new file mode 100644 index 0000000..1a1139c --- /dev/null +++ b/python-construct-2.10.68-fixed-passing-self-instead-of-stream.patch @@ -0,0 +1,42 @@ +From 188b0c709a2312714d25a72169acae805649f822 Mon Sep 17 00:00:00 2001 +From: Arkadiusz Bulski +Date: Sun, 18 Sep 2022 16:20:04 +0200 +Subject: [PATCH] Bug #938 fixed (thanks Henrique) + +--- + construct/core.py | 2 +- + tests/test_core.py | 5 +++++ + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/construct/core.py b/construct/core.py +index 129abe5..e31e8e9 100644 +--- a/construct/core.py ++++ b/construct/core.py +@@ -5594,7 +5594,7 @@ class Lazy(Subconstruct): + obj = self.subcon._parsereport(stream, context, path) + stream_seek(stream, fallback, 0, path) + return obj +- len = self.subcon._actualsize(self, context, path) ++ len = self.subcon._actualsize(stream, context, path) + stream_seek(stream, len, 1, path) + return execute + +diff --git a/tests/test_core.py b/tests/test_core.py +index ea00810..b6465c5 100644 +--- a/tests/test_core.py ++++ b/tests/test_core.py +@@ -1328,6 +1328,11 @@ def test_lazy(): + assert d.build(x) == b'\x00' + assert d.sizeof() == 1 + ++def test_lazy_issue_938(): ++ d = Lazy(Prefixed(Byte, Byte)) ++ func = d.parse(b'\x01\x02') ++ assert func() == 2 ++ + def test_lazy_seek(): + d = Struct( + "a" / Int8ub, +-- +2.39.0.windows.2 + diff --git a/python-construct.spec b/python-construct.spec index 2ba9ec7..0982e78 100644 --- a/python-construct.spec +++ b/python-construct.spec @@ -1,11 +1,12 @@ %global _empty_manifest_terminate_build 0 Name: python-construct Version: 2.10.68 -Release: 1 +Release: 2 Summary: A powerful declarative symmetric parser/builder for binary data License: MIT URL: http://construct.readthedocs.org Source0: https://pypi.python.org/packages/source/c/construct/construct-%{version}.tar.gz +Patch0001: python-construct-2.10.68-fixed-passing-self-instead-of-stream.patch BuildArch: noarch %description Construct is a powerful declarative and symmetrical parser and builder for binary data. @@ -28,7 +29,7 @@ Construct is a powerful declarative and symmetrical parser and builder for binar Instead of writing imperative code to parse a piece of data, you declaratively define a data structure that describes your data. As this data structure is not code, you can use it in one direction to parse data into Pythonic objects, and in the other direction, to build objects into binary data. %prep -%autosetup -n construct-%{version} +%autosetup -n construct-%{version} -p1 %build %py3_build @@ -68,6 +69,9 @@ mv %{buildroot}/doclist.lst . %{_docdir}/* %changelog +* Sat Jan 7 2023 zhangliangpengkun - 2.10.68-2 +- Fixed passing self instead of stream + * Fri Jun 17 2022 houyingchao - 2.10.68-1 - Upgrade to version 2.10.68 -- Gitee