commit python-construct for openSUSE:Factory
Hello community, here is the log from the commit of package python-construct for openSUSE:Factory checked in at 2017-09-04 12:25:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-construct (Old) and /work/SRC/openSUSE:Factory/.python-construct.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-construct" Mon Sep 4 12:25:15 2017 rev:9 rq:518920 version:2.8.12 Changes: -------- --- /work/SRC/openSUSE:Factory/python-construct/python-construct.changes 2017-05-09 17:59:45.557640890 +0200 +++ /work/SRC/openSUSE:Factory/.python-construct.new/python-construct.changes 2017-09-04 12:25:24.559576230 +0200 @@ -1,0 +2,15 @@ +Sat Aug 26 16:52:44 UTC 2017 - jengelh@inai.de + +- Rewrite description for more neutrality. + +------------------------------------------------------------------- +Thu Aug 24 07:24:54 UTC 2017 - tbechtold@suse.com + +- update to 2.8.12: + * README and docs updated + * Version uped to 2.8.12 + * Union: fixed buildfrom (bug #348) + * Docs updated: API reference + * Prefixed instead of Array (#349) + +------------------------------------------------------------------- Old: ---- construct-2.8.11.tar.gz New: ---- construct-2.8.12.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-construct.spec ++++++ --- /var/tmp/diff_new_pack.TXAJ3Q/_old 2017-09-04 12:25:26.715273157 +0200 +++ /var/tmp/diff_new_pack.TXAJ3Q/_new 2017-09-04 12:25:26.731270908 +0200 @@ -18,9 +18,9 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-construct -Version: 2.8.11 +Version: 2.8.12 Release: 0 -Summary: A powerful declarative parser/builder for binary data +Summary: A declarative parser/builder for binary data License: MIT Group: Development/Languages/Python Url: http://construct.readthedocs.org @@ -37,12 +37,12 @@ %python_subpackages %description -Construct is a powerful declarative parser (and builder) for binary data. +Construct is a declarative parser (and builder) for binary data. -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, convert ("build") objects into binary data. +Instead of writing imperative code to parse a piece of data, a data +structure that describes the data is declared. As this data structure is not +code, it can be used in one direction to parse data into Pythonic objects, +and in the other direction to convert ("build") objects into binary data. %prep %setup -q -n construct-%{version} ++++++ construct-2.8.11.tar.gz -> construct-2.8.12.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/README.rst new/construct-2.8.12/README.rst --- old/construct-2.8.11/README.rst 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/README.rst 2017-04-25 00:35:54.000000000 +0200 @@ -3,7 +3,7 @@ Construct is a powerful **declarative** parser (and builder) for binary data. -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, build objects into binary data. +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. The library provides both simple, atomic constructs (such as integers of various sizes), as well as composite ones which allow you form hierarchical and sequential structures of increasing complexity. Construct features **bit and byte granularity**, easy debugging and testing, an **easy-to-extend subclass system**, and lots of primitive constructs to make your work easier: @@ -47,7 +47,7 @@ Sticky -------- -Version 2.5.5 is the previous stable release. If you are maintaining a project that depended on this framework for a long time, you should probably use this version. This branch is not actively maintained. Even bugfixes are not being added. +Version 2.5.5 is the previous stable release. If you are maintaining a project that depended on this framework for a long time, you should probably use this version. This branch is not actively maintained. Version 2.8 was released September, 2016. There are significant API and implementation changes. Fields are now name-less and operators / >> are used to construct Structs and Sequences. Most classes were redesigned and reimplemented. You should read the documentation again. @@ -58,7 +58,7 @@ Construct's main documentation is at `construct.readthedocs.org http://construct.readthedocs.org`_, where you can find all kinds of examples. The library itself is developed on `github https://github.com/construct/construct`_. Releases are also available on `pypi https://pypi.python.org/pypi/construct`_. -`Construct3 http://tomerfiliba.com/blog/Survey-of-Construct3/`_ is a different project. It is a rewrite from scratch and belongs to another developer, it diverged from this project. As far as I can tell, it was not released yet. +`Construct3 http://tomerfiliba.com/blog/Survey-of-Construct3/`_ is a different project. It is a rewrite from scratch and belongs to another developer, it diverged from this project. As far as I can tell, it was not released and abandonded. Requirements diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/construct/core.py new/construct-2.8.12/construct/core.py --- old/construct-2.8.11/construct/core.py 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/construct/core.py 2017-04-25 00:35:54.000000000 +0200 @@ -1089,10 +1089,10 @@ def PrefixedArray(lengthfield, subcon): r""" - An array prefixed by a length field (as opposed to preixed by byte count, see :func:`~construct.core.Array`). + An array prefixed by a length field (as opposed to prefixed by byte count, see :func:`~construct.core.Prefixed`). - :param lengthfield: a field parsing and building an integer - :param subcon: the subcon to process individual elements + :param lengthfield: field parsing and building an integer + :param subcon: subcon to process individual elements Example:: @@ -1329,9 +1329,9 @@ r""" Treats the same data as multiple constructs (similar to C union statement) so you can "look" at the data in multiple views. - When parsing, all fields read the same data bytes, but stream remains at same offset by default, unless buildfrom selects a subcon. When building, either the first subcon that can find an entry in given dict is allowed to put into the stream, or the subcon is selected by index or name, or builds nothing. + When parsing, all fields read the same data bytes, but stream remains at initial offset by default, unless buildfrom selects a subcon. When building, either the first subcon that can find an entry in given dict is allowed to put into the stream, or the subcon is selected by index or name, or builds nothing. - WARNING: If you skip the `buildfrom` parameter then parsing will not advance the stream, because subcons can be of different sizes. + .. warning:: If you skip the `buildfrom` parameter then parsing will not advance the stream, because subcons can be of different sizes. :param subcons: subconstructs (order and name sensitive) :param buildfrom: optional, how to build, the subcon used for building and calculating size, can be integer index or string name selecting a subcon, None (then tries each subcon in sequence, the default), Pass (builds nothing), a context lambda returning either of previously mentioned @@ -1347,7 +1347,7 @@ b'\x00\x01\x02\x03\x04\x05\x06\x07' Note that this syntax works ONLY on python 3.6 due to unordered keyword arguments: - >>> Union(raw=Bytes(8), ints=Int32ub[2], shorts=Int16ub[4], chars=Byte[8], buildfrom=3) + >>> Union(raw=Bytes(8), ints=Int32ub[2], shorts=Int16ub[4], chars=Int8ub[8], buildfrom=3) """ __slots__ = ["subcons","buildfrom"] def __init__(self, *subcons, **kw): @@ -1356,11 +1356,13 @@ if k not in ["buildfrom"]: subcons.append(k / v) super(Union, self).__init__() - self.subcons = [Peek(sc) for sc in subcons] + self.subcons = subcons self.buildfrom = kw.get("buildfrom") def _parse(self, stream, context, path): obj = Container() context = Container(_ = context) + fallback = stream.tell() + forwards = {} for i,sc in enumerate(self.subcons): if sc.flagembedded: subobj = list(sc._parse(stream, context, path).items()) @@ -1371,24 +1373,25 @@ if sc.name is not None: obj[sc.name] = subobj context[sc.name] = subobj - if callable(self.buildfrom): - self.buildfrom = self.buildfrom(context) - if isinstance(self.buildfrom, int): - jump = self.subcons[self.buildfrom].subcon._sizeof(context, path) - stream.seek(jump, 1) - if isinstance(self.buildfrom, str): - index = [i for i,sc in enumerate(self.subcons) if sc.name == self.buildfrom][0] - jump = self.subcons[index].subcon._sizeof(context, path) - stream.seek(jump, 1) + forwards[i] = stream.tell() + if sc.name is not None: + forwards[sc.name] = stream.tell() + stream.seek(fallback) + buildfrom = self.buildfrom + if callable(buildfrom): + buildfrom = buildfrom(context) + if isinstance(buildfrom, (int,str)): + stream.seek(forwards[buildfrom]) return obj def _build(self, obj, stream, context, path): context = Container(_ = context) context.update(obj) - if callable(self.buildfrom): - self.buildfrom = self.buildfrom(context) - if self.buildfrom is Pass: + buildfrom = self.buildfrom + if callable(buildfrom): + buildfrom = buildfrom(context) + if buildfrom is Pass: return - if self.buildfrom is None: + if buildfrom is None: for i,sc in enumerate(self.subcons): if sc.subcon.flagbuildnone: subobj = obj.get(sc.name, None) @@ -1410,31 +1413,32 @@ return buildret else: raise UnionError("none of subcons %s were found in the dictionary %s" % (self.subcons, obj)) - if isinstance(self.buildfrom, int): - sc = self.subcons[self.buildfrom] - # pass the full object if building an embedded union member + if isinstance(buildfrom, int): + sc = self.subcons[buildfrom] obj2 = obj if sc.flagembedded else obj[sc.name] - return sc.subcon._build(obj2, stream, context, path) + return sc._build(obj2, stream, context, path) if isinstance(self.buildfrom, str): - index = [i for i,sc in enumerate(self.subcons) if sc.name == self.buildfrom][0] - sc = self.subcons[index] - return sc.subcon._build(obj[sc.name], stream, context, path) + sc = {sc.name:sc for sc in self.subcons if sc.name is not None}[buildfrom] + obj2 = obj if sc.flagembedded else obj[sc.name] + return sc._build(obj2, stream, context, path) raise UnionError("buildfrom should be either: None, Pass, an int, a str") def _sizeof(self, context, path): + buildfrom = self.buildfrom try: - if callable(self.buildfrom): - self.buildfrom = self.buildfrom(context) + if callable(buildfrom): + buildfrom = buildfrom(context) except (KeyError, AttributeError): raise SizeofError("cannot calculate size, key not found in context") - if self.buildfrom is Pass: + if buildfrom is Pass: return 0 - if self.buildfrom is None: + if buildfrom is None: raise SizeofError("cannot calculate size") - if isinstance(self.buildfrom, int): - return self.subcons[self.buildfrom].subcon._sizeof(context, path) - if isinstance(self.buildfrom, str): - index = [i for i,sc in enumerate(self.subcons) if sc.name == self.buildfrom][0] - return self.subcons[index].subcon._sizeof(context, path) + if isinstance(buildfrom, int): + sc = self.subcons[buildfrom] + return sc._sizeof(context, path) + if isinstance(buildfrom, str): + sc = {sc.name:sc for sc in self.subcons if sc.name is not None}[buildfrom] + return sc._sizeof(context, path) raise UnionError("buildfrom should be either: None, Pass, an int, a str") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/construct/version.py new/construct-2.8.12/construct/version.py --- old/construct-2.8.11/construct/version.py 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/construct/version.py 2017-04-25 00:35:54.000000000 +0200 @@ -1,3 +1,3 @@ -version = (2, 8, 11) -version_string = "2.8.11" -release_date = "2017.04.05" +version = (2, 8, 12) +version_string = "2.8.12" +release_date = "2017.04.25" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/align.rst new/construct-2.8.12/docs/api/align.rst --- old/construct-2.8.11/docs/api/align.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/construct-2.8.12/docs/api/align.rst 2017-04-25 00:35:54.000000000 +0200 @@ -0,0 +1,7 @@ +=============================== +Core API: Alignment and Padding +=============================== + +.. autofunction:: construct.Padding +.. autofunction:: construct.Padded +.. autofunction:: construct.Aligned diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/bytes.rst new/construct-2.8.12/docs/api/bytes.rst --- old/construct-2.8.11/docs/api/bytes.rst 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/docs/api/bytes.rst 2017-04-25 00:35:54.000000000 +0200 @@ -3,12 +3,7 @@ ======================== .. autofunction:: construct.Bytes - .. autofunction:: construct.GreedyBytes - .. autofunction:: construct.Bitwise - .. autofunction:: construct.BytesInteger - .. autofunction:: construct.BitsInteger - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/debugging.rst new/construct-2.8.12/docs/api/debugging.rst --- old/construct-2.8.11/docs/api/debugging.rst 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/docs/api/debugging.rst 2017-04-25 00:35:54.000000000 +0200 @@ -3,6 +3,4 @@ ================================ .. automodule:: construct.debug - .. autofunction:: construct.Error - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/lazy.rst new/construct-2.8.12/docs/api/lazy.rst --- old/construct-2.8.11/docs/api/lazy.rst 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/docs/api/lazy.rst 2017-04-25 00:35:54.000000000 +0200 @@ -3,15 +3,8 @@ =============================== .. autofunction:: construct.LazyStruct - .. autofunction:: construct.LazySequence - .. autofunction:: construct.LazyRange - .. autofunction:: construct.OnDemand - .. autofunction:: construct.OnDemandPointer - .. autofunction:: construct.LazyBound - - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/lib.rst new/construct-2.8.12/docs/api/lib.rst --- old/construct-2.8.11/docs/api/lib.rst 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/docs/api/lib.rst 2017-04-25 00:35:54.000000000 +0200 @@ -3,4 +3,3 @@ ========================================== .. automodule:: construct.lib - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/misc.rst new/construct-2.8.12/docs/api/misc.rst --- old/construct-2.8.11/docs/api/misc.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/construct-2.8.12/docs/api/misc.rst 2017-04-25 00:35:54.000000000 +0200 @@ -0,0 +1,12 @@ +=============================== +Core API: Miscellaneous +=============================== + +.. autofunction:: construct.Const +.. autofunction:: construct.Computed +.. autofunction:: construct.Numpy +.. autofunction:: construct.NamedTuple +.. autofunction:: construct.Rebuild +.. autofunction:: construct.Check +.. autofunction:: construct.FocusedSeq +.. autofunction:: construct.Default diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/repeaters.rst new/construct-2.8.12/docs/api/repeaters.rst --- old/construct-2.8.11/docs/api/repeaters.rst 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/docs/api/repeaters.rst 2017-04-25 00:35:54.000000000 +0200 @@ -2,15 +2,8 @@ Core API: Repeaters ========================================== - .. autofunction:: construct.Array - .. autofunction:: construct.PrefixedArray - .. autofunction:: construct.Range - .. autofunction:: construct.GreedyRange - .. autofunction:: construct.RepeatUntil - - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/streaming.rst new/construct-2.8.12/docs/api/streaming.rst --- old/construct-2.8.11/docs/api/streaming.rst 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/docs/api/streaming.rst 2017-04-25 00:35:54.000000000 +0200 @@ -3,15 +3,10 @@ =============================== .. autofunction:: construct.Pointer - .. autofunction:: construct.Peek - .. autofunction:: construct.Tell - .. autofunction:: construct.Seek - +.. autofunction:: construct.Pass +.. autofunction:: construct.Terminated .. autofunction:: construct.Restreamed - .. autofunction:: construct.Rebuffered - - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/strings.rst new/construct-2.8.12/docs/api/strings.rst --- old/construct-2.8.11/docs/api/strings.rst 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/docs/api/strings.rst 2017-04-25 00:35:54.000000000 +0200 @@ -3,12 +3,7 @@ =================== .. autofunction:: construct.setglobalstringencoding - .. autofunction:: construct.String - .. autofunction:: construct.PascalString - .. autofunction:: construct.CString - .. autofunction:: construct.GreedyString - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/structs.rst new/construct-2.8.12/docs/api/structs.rst --- old/construct-2.8.11/docs/api/structs.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/construct-2.8.12/docs/api/structs.rst 2017-04-25 00:35:54.000000000 +0200 @@ -0,0 +1,17 @@ +=============================== +Core API: Structs and Sequences +=============================== + +.. autofunction:: construct.Struct +.. autofunction:: construct.Sequence +.. autofunction:: construct.Embedded +.. autofunction:: construct.StopIf +.. autofunction:: construct.Union +.. autofunction:: construct.Select +.. autofunction:: construct.Optional +.. autofunction:: construct.If +.. autofunction:: construct.IfThenElse +.. autofunction:: construct.Switch +.. autofunction:: construct.AlignedStruct +.. autofunction:: construct.BitStruct +.. autofunction:: construct.EmbeddedBitStruct diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/structseq.rst new/construct-2.8.12/docs/api/structseq.rst --- old/construct-2.8.11/docs/api/structseq.rst 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/docs/api/structseq.rst 1970-01-01 01:00:00.000000000 +0100 @@ -1,17 +0,0 @@ -=============================== -Core API: Structs and Sequences -=============================== - -.. autofunction:: construct.Struct - -.. autofunction:: construct.Sequence - -.. autofunction:: construct.Embedded - -.. autofunction:: construct.StopIf - -.. autofunction:: construct.AlignedStruct - -.. autofunction:: construct.BitStruct - -.. autofunction:: construct.EmbeddedBitStruct diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/api/tunneling.rst new/construct-2.8.12/docs/api/tunneling.rst --- old/construct-2.8.11/docs/api/tunneling.rst 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/docs/api/tunneling.rst 2017-04-25 00:35:54.000000000 +0200 @@ -3,15 +3,8 @@ =============================== .. autofunction:: construct.RawCopy - .. autofunction:: construct.ByteSwapped - .. autofunction:: construct.BitsSwapped - .. autofunction:: construct.Prefixed - .. autofunction:: construct.Checksum - .. autofunction:: construct.Compressed - - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/docs/index.rst new/construct-2.8.12/docs/index.rst --- old/construct-2.8.11/docs/index.rst 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/docs/index.rst 2017-04-25 00:35:54.000000000 +0200 @@ -37,19 +37,19 @@ <strong>Sticky</strong><br/> - <a class="reference external" href="https://github.com/construct/construct/releases">Version 2.5.5</a> is the previous stable release. If you are maintaining a project that depended on this framework for a long time, you should probably use this version. This branch is not actively maintained. Only bugfixes will be added.<br/> + <a class="reference external" href="https://github.com/construct/construct/releases">Version 2.5.5</a> is the previous stable release. If you are maintaining a project that depended on this library for a long time, you should probably use this version. This branch is not actively maintained.<br/> <br/> - <a class="reference external" href="https://github.com/construct/construct/releases">Version 2.8</a> was released on September, 2016. There are significant API and implementation changes. Fields are now name-less and operators / >> are used to construct Structs and Sequences. Most classes were redesigned and reimplemented. You should read the documentation again.<br/> + <a class="reference external" href="https://github.com/construct/construct/releases">Version 2.8</a> was released on September, 2016. There are significant API and implementation changes. Fields are now name-less and operators / >> are used to construct Structs and Sequences. Most classes changed interface and behavior. You should read the documentation again.<br/> <br/> - Please use the <a class="reference external" href="https://github.com/construct/construct/issues">github issues</a> to ask general questions, make feature requests, report issues and bugs, and to send in patches.<br/> + Please use the <a class="reference external" href="https://github.com/construct/construct/issues">github issues</a> to ask general questions, make feature requests, report issues and bugs, and to send in patches. Good quality extensions to test suite are highly welcomed.<br/> </div> Construct is a powerful **declarative** parser (and builder) for binary data. -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, build objects into binary data. +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. The library provides both simple, atomic constructs (such as integers of various sizes), as well as composite ones which allow you form hierarchical and sequential structures of increasing complexity. Construct features **bit and byte granularity**, easy debugging and testing, an **easy-to-extend subclass system**, and lots of primitive constructs to make your work easier: @@ -97,7 +97,7 @@ Construct's main documentation is at `construct.readthedocs.org http://construct.readthedocs.org`_, where you can find all kinds of examples. The library itself is developed on `github https://github.com/construct/construct`_. Releases are also available on `pypi https://pypi.python.org/pypi/construct`_. -`Construct3 http://tomerfiliba.com/blog/Survey-of-Construct3/`_ is a different project. It is a rewrite from scratch and belongs to another developer, it diverged from this project. As far as I can tell, it was not released yet. +`Construct3 http://tomerfiliba.com/blog/Survey-of-Construct3/`_ is a different project. It is a rewrite from scratch and belongs to another developer, it diverged from this project. As far as I can tell, it was not released and abandoned. Requirements @@ -135,9 +135,11 @@ api/bytes api/strings - api/structseq + api/structs api/repeaters api/lazy + api/misc + api/align api/streaming api/tunneling api/debugging diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/construct-2.8.11/tests/test_all.py new/construct-2.8.12/tests/test_all.py --- old/construct-2.8.11/tests/test_all.py 2017-04-05 23:02:36.000000000 +0200 +++ new/construct-2.8.12/tests/test_all.py 2017-04-25 00:35:54.000000000 +0200 @@ -671,15 +671,17 @@ assert Union("a"/Bytes(2), "b"/Int16ub, buildfrom="a").build(dict(a=b"zz",b=5)) == b"zz" assert Union("a"/Bytes(2), "b"/Int16ub, buildfrom="b").build(dict(a=b"zz",b=5)) == b"\x00\x05" assert Union("a"/Bytes(2), "b"/Int16ub, buildfrom=Pass).build({}) == b"" - assert raises(Union(Pass, buildfrom=123).parse, b"") == IndexError - assert raises(Union(Pass, buildfrom="missing").build, {}) == IndexError + assert raises(Union(Pass, buildfrom=123).parse, b"") == KeyError + assert raises(Union(Pass, buildfrom="missing").parse, b"") == KeyError + assert raises(Union(Pass, buildfrom=123).build, {}) == IndexError + assert raises(Union(Pass, buildfrom="missing").build, {}) == KeyError assert raises(Union(Byte).sizeof) == SizeofError assert raises(Union(VarInt).sizeof) == SizeofError assert Union(Byte, VarInt, buildfrom=0).sizeof() == 1 assert raises(Union(Byte, VarInt, buildfrom=1).sizeof) == SizeofError assert raises(Union(Pass, buildfrom=123).sizeof) == IndexError - assert raises(Union(Pass, buildfrom="missing").sizeof) == IndexError + assert raises(Union(Pass, buildfrom="missing").sizeof) == KeyError assert raises(Union(Pass, buildfrom=this.missing).sizeof) == SizeofError assert (Union("b"/Int16ub) >> Byte).parse(b"\x01\x02\x03") == [Container(b=0x0102),0x01] @@ -701,6 +703,14 @@ assert st.parse(b"\x01\x02\x03\x04") == Container(a=0x01,b=0x0102,c=0x01020304) assert st.build(Container(c=0x01020304)) == b"\x01\x02\x03\x04" + def test_union_issue_348(self): + u = Union( + Int8=Prefixed(Int16ub, Int8ub[:]), + Int16=Prefixed(Int16ub, Int16ub[:]), + Int32=Prefixed(Int16ub, Int32ub[:]), + buildfrom=0) + assert u.parse(b'\x00\x04\x11\x22\x33\x44') == {'Int16': [4386, 13124], 'Int32': [287454020], 'Int8': [17, 34, 51, 68]} + def test_prefixed(self): assert Prefixed(Byte, Int16ul).parse(b"\x02\xff\xff??????") == 65535 assert Prefixed(Byte, Int16ul).build(65535) == b"\x02\xff\xff"
participants (1)
-
root@hilbert.suse.de