Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-bitstruct for 
openSUSE:Factory checked in at 2023-05-08 17:24:06
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-bitstruct (Old)
 and      /work/SRC/openSUSE:Factory/.python-bitstruct.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-bitstruct"

Mon May  8 17:24:06 2023 rev:5 rq:1085336 version:8.17.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-bitstruct/python-bitstruct.changes        
2022-09-12 19:08:22.074556516 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-bitstruct.new.1533/python-bitstruct.changes  
    2023-05-08 17:24:07.592639392 +0200
@@ -1,0 +2,8 @@
+Sun May  7 18:50:29 UTC 2023 - Dirk Müller <[email protected]>
+
+- update to 8.17.0:
+  * Text encoding and error action to unpack operations
+  * Fix memory leak
+  * Fix Text encoding and Errors to compile 
+
+-------------------------------------------------------------------

Old:
----
  bitstruct-8.15.1.tar.gz

New:
----
  bitstruct-8.17.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-bitstruct.spec ++++++
--- /var/tmp/diff_new_pack.CKSTEl/_old  2023-05-08 17:24:08.060642159 +0200
+++ /var/tmp/diff_new_pack.CKSTEl/_new  2023-05-08 17:24:08.064642183 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-bitstruct
 #
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
 # Copyright (c) 2020, Martin Hauke <[email protected]>
 #
 # All modifications and additions to the file contributed by third parties
@@ -20,7 +20,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %define skip_python2 1
 Name:           python-bitstruct
-Version:        8.15.1
+Version:        8.17.0
 Release:        0
 Summary:        Interpret strings as packed binary data
 License:        MIT

++++++ bitstruct-8.15.1.tar.gz -> bitstruct-8.17.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bitstruct-8.15.1/PKG-INFO 
new/bitstruct-8.17.0/PKG-INFO
--- old/bitstruct-8.15.1/PKG-INFO       2022-06-07 21:58:17.036622000 +0200
+++ new/bitstruct-8.17.0/PKG-INFO       2023-02-17 21:04:55.810826800 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: bitstruct
-Version: 8.15.1
+Version: 8.17.0
 Summary: This module performs conversions between Python values and C bit 
field structs represented as Python byte strings.
 Home-page: https://github.com/eerimoq/bitstruct
 Author: Erik Moqvist, Ilya Petukhov
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bitstruct-8.15.1/bitstruct/__init__.py 
new/bitstruct-8.17.0/bitstruct/__init__.py
--- old/bitstruct-8.15.1/bitstruct/__init__.py  2022-06-07 21:58:05.000000000 
+0200
+++ new/bitstruct-8.17.0/bitstruct/__init__.py  2023-02-17 21:04:47.000000000 
+0100
@@ -154,6 +154,11 @@
 
 class _Text(_Info):
 
+    def __init__(self, size, name, encoding, errors):
+        super(_Text, self).__init__(size, name)
+        self.encoding = encoding
+        self.errors = errors
+
     def pack(self, arg):
         encoded = arg.encode('utf-8')
         number_of_padding_bytes = ((self.size - 8 * len(encoded)) // 8)
@@ -162,10 +167,10 @@
         return _pack_bytearray(self.size, encoded)
 
     def unpack(self, bits):
-        return _unpack_bytearray(self.size, bits).decode('utf-8')
+        return _unpack_bytearray(self.size, bits).decode(self.encoding, 
self.errors)
 
 
-def _parse_format(fmt, names):
+def _parse_format(fmt, names, text_encoding, text_errors):
     if fmt and fmt[-1] in '><':
         byte_order = fmt[-1]
         fmt = fmt[:-1]
@@ -211,7 +216,7 @@
             info = _Boolean(size, name)
             i += 1
         elif type_ == 't':
-            info = _Text(size, name)
+            info = _Text(size, name, text_encoding, text_errors)
             i += 1
         elif type_ == 'r':
             info = _Raw(size, name)
@@ -245,8 +250,12 @@
 
 class _CompiledFormat(object):
 
-    def __init__(self, fmt, names=None):
-        infos, byte_order = _parse_format(fmt, names)
+    def __init__(self,
+                 fmt,
+                 names=None,
+                 text_encoding='utf-8',
+                 text_errors='strict'):
+        infos, byte_order = _parse_format(fmt, names, text_encoding, 
text_errors)
         self._infos = infos
         self._byte_order = byte_order
         self._number_of_bits_to_unpack = sum([info.size for info in infos])
@@ -377,8 +386,8 @@
 
     """
 
-    def __init__(self, fmt):
-        super(CompiledFormat, self).__init__(fmt, None)
+    def __init__(self, fmt, text_encoding='utf-8', text_errors='strict'):
+        super(CompiledFormat, self).__init__(fmt, None, text_encoding, 
text_errors)
         self._number_of_arguments = 0
 
         for info in self._infos:
@@ -469,6 +478,7 @@
             info.name: v for info, v in self.unpack_from_any(
                 data, offset, allow_truncated=allow_truncated)}
 
+
 def pack(fmt, *args):
     """Return a bytes object containing the values v1, v2, ... packed
     according to given format string `fmt`. If the total number of
@@ -521,16 +531,27 @@
     return CompiledFormat(fmt).pack(*args)
 
 
-def unpack(fmt, data, allow_truncated=False):
+def unpack(fmt,
+           data,
+           allow_truncated=False,
+           text_encoding='utf-8',
+           text_errors='strict'):
     """Unpack `data` (bytes or bytearray) according to given format string
-    `fmt`. If `allow_truncated` is `True`, `data` may be shorter than
-    the number of items specified by `fmt`; in this case, only the
+    `fmt`.
+
+    If `allow_truncated` is `True`, `data` may be shorter than the
+    number of items specified by `fmt`; in this case, only the
     complete items will be unpacked. The result is a tuple even if it
     contains exactly one item.
 
+    Text fields are decoded with given encoding `text_encoding` and
+    error handling as given by `text_errors` (both passed to
+    `bytes.decode()`).
+
     """
 
-    return CompiledFormat(fmt).unpack(data, allow_truncated=allow_truncated)
+    return CompiledFormat(fmt, text_encoding, text_errors).unpack(
+        data, allow_truncated=allow_truncated)
 
 
 def pack_into(fmt, buf, offset, *args, **kwargs):
@@ -547,7 +568,12 @@
                                          **kwargs)
 
 
-def unpack_from(fmt, data, offset=0, allow_truncated=False):
+def unpack_from(fmt,
+                data,
+                offset=0,
+                allow_truncated=False,
+                text_encoding='utf-8',
+                text_errors='strict'):
     """Unpack `data` (bytes or bytearray) according to given format string
     `fmt`, starting at given bit offset `offset`. If `allow_truncated`
     is `True`, `data` may be shorter than the number of items
@@ -557,7 +583,7 @@
 
     """
 
-    return CompiledFormat(fmt).unpack_from(
+    return CompiledFormat(fmt, text_encoding, text_errors).unpack_from(
         data, offset, allow_truncated=allow_truncated)
 
 
@@ -576,7 +602,12 @@
     return CompiledFormatDict(fmt, names).pack(data)
 
 
-def unpack_dict(fmt, names, data, allow_truncated=False):
+def unpack_dict(fmt,
+                names,
+                data,
+                allow_truncated=False,
+                text_encoding='utf-8',
+                text_errors='strict'):
     """Same as :func:`~bitstruct.unpack()`, but returns a dictionary.
 
     See :func:`~bitstruct.pack_dict()` for details on `names`.
@@ -586,7 +617,7 @@
 
     """
 
-    return CompiledFormatDict(fmt, names).unpack(
+    return CompiledFormatDict(fmt, names, text_encoding, text_errors).unpack(
         data, allow_truncated=allow_truncated)
 
 
@@ -604,7 +635,13 @@
                                                     **kwargs)
 
 
-def unpack_from_dict(fmt, names, data, offset=0, allow_truncated=False):
+def unpack_from_dict(fmt,
+                     names,
+                     data,
+                     offset=0,
+                     allow_truncated=False,
+                     text_encoding='utf-8',
+                     text_errors='strict'):
     """Same as :func:`~bitstruct.unpack_from()`, but returns a
     dictionary.
 
@@ -612,7 +649,7 @@
 
     """
 
-    return CompiledFormatDict(fmt, names).unpack_from(
+    return CompiledFormatDict(fmt, names, text_encoding, 
text_errors).unpack_from(
         data, offset, allow_truncated=allow_truncated)
 
 
@@ -647,7 +684,10 @@
     return data_swapped.getvalue()
 
 
-def compile(fmt, names=None):
+def compile(fmt,
+            names=None,
+            text_encoding='utf-8',
+            text_errors='strict'):
     """Compile given format string `fmt` and return a compiled format
     object that can be used to pack and/or unpack data multiple times.
 
@@ -657,9 +697,12 @@
 
     See :func:`~bitstruct.pack_dict()` for details on `names`.
 
+    See :func:`~bitstruct.unpack()` for details on `text_encoding` and
+    `text_errors`.
+
     """
 
     if names is None:
-        return CompiledFormat(fmt)
+        return CompiledFormat(fmt, text_encoding, text_errors)
     else:
-        return CompiledFormatDict(fmt, names)
+        return CompiledFormatDict(fmt, names, text_encoding, text_errors)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bitstruct-8.15.1/bitstruct/c.c 
new/bitstruct-8.17.0/bitstruct/c.c
--- old/bitstruct-8.15.1/bitstruct/c.c  2022-06-07 21:58:05.000000000 +0200
+++ new/bitstruct-8.17.0/bitstruct/c.c  2023-02-17 21:04:47.000000000 +0100
@@ -1957,6 +1957,7 @@
 {
     PyMem_RawFree(self_p->info_p);
     Py_DECREF(self_p->format_p);
+    Py_TYPE(self_p)->tp_free((PyObject *)self_p);
 }
 
 static PyObject *m_compiled_format_pack(struct compiled_format_t *self_p,
@@ -2237,6 +2238,7 @@
     PyMem_RawFree(self_p->info_p);
     Py_DECREF(self_p->names_p);
     Py_DECREF(self_p->format_p);
+    Py_TYPE(self_p)->tp_free((PyObject *)self_p);
 }
 
 static PyObject *m_compiled_format_dict_pack(struct compiled_format_dict_t 
*self_p,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bitstruct-8.15.1/bitstruct/version.py 
new/bitstruct-8.17.0/bitstruct/version.py
--- old/bitstruct-8.15.1/bitstruct/version.py   2022-06-07 21:58:05.000000000 
+0200
+++ new/bitstruct-8.17.0/bitstruct/version.py   2023-02-17 21:04:47.000000000 
+0100
@@ -1 +1 @@
-__version__ = '8.15.1'
+__version__ = '8.17.0'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bitstruct-8.15.1/bitstruct.egg-info/PKG-INFO 
new/bitstruct-8.17.0/bitstruct.egg-info/PKG-INFO
--- old/bitstruct-8.15.1/bitstruct.egg-info/PKG-INFO    2022-06-07 
21:58:16.000000000 +0200
+++ new/bitstruct-8.17.0/bitstruct.egg-info/PKG-INFO    2023-02-17 
21:04:55.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: bitstruct
-Version: 8.15.1
+Version: 8.17.0
 Summary: This module performs conversions between Python values and C bit 
field structs represented as Python byte strings.
 Home-page: https://github.com/eerimoq/bitstruct
 Author: Erik Moqvist, Ilya Petukhov
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/bitstruct-8.15.1/tests/test_bitstruct.py 
new/bitstruct-8.17.0/tests/test_bitstruct.py
--- old/bitstruct-8.15.1/tests/test_bitstruct.py        2022-06-07 
21:58:05.000000000 +0200
+++ new/bitstruct-8.17.0/tests/test_bitstruct.py        2023-02-17 
21:04:47.000000000 +0100
@@ -640,6 +640,26 @@
         unpacked = unpack('t24', b'1234')[0]
         self.assertEqual(unpacked, '123')
 
+        unpacked = unpack('t8', b'\xff', text_errors='replace')[0]
+        self.assertEqual(unpacked, '�')
+        unpacked = unpack('t8', b'\xff', text_errors='ignore')[0]
+        self.assertEqual(unpacked, '')
+
+        cf = bitstruct.compile('t8', text_encoding='latin-1', 
text_errors='replace')
+        unpacked = cf.unpack(b'\xff')[0]
+        self.assertEqual(unpacked, 'ÿ')
+
+        cf = bitstruct.compile('t8', text_encoding='utf-8', 
text_errors='ignore')
+        unpacked = cf.unpack(b'\xff')[0]
+        self.assertEqual(unpacked, '')
+
+        cf = bitstruct.compile('t8',
+                               names=['a'],
+                               text_encoding='utf-8',
+                               text_errors='replace')
+        unpacked = cf.unpack(b'\xff')
+        self.assertEqual(unpacked, {'a': '�'})
+
     def test_pack_unpack_dict(self):
         unpacked = {
             'foo': 0,

Reply via email to