bitstruct 8.22.0__tar.gz → 8.22.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {bitstruct-8.22.0/src/bitstruct.egg-info → bitstruct-8.22.2}/PKG-INFO +1 -1
  2. {bitstruct-8.22.0 → bitstruct-8.22.2}/src/bitstruct/__init__.py +1 -1
  3. {bitstruct-8.22.0 → bitstruct-8.22.2}/src/bitstruct/c.c +11 -4
  4. {bitstruct-8.22.0 → bitstruct-8.22.2/src/bitstruct.egg-info}/PKG-INFO +1 -1
  5. {bitstruct-8.22.0 → bitstruct-8.22.2}/tests/test_c.py +6 -0
  6. {bitstruct-8.22.0 → bitstruct-8.22.2}/LICENSE +0 -0
  7. {bitstruct-8.22.0 → bitstruct-8.22.2}/MANIFEST.in +0 -0
  8. {bitstruct-8.22.0 → bitstruct-8.22.2}/Makefile +0 -0
  9. {bitstruct-8.22.0 → bitstruct-8.22.2}/README.rst +0 -0
  10. {bitstruct-8.22.0 → bitstruct-8.22.2}/docs/Makefile +0 -0
  11. {bitstruct-8.22.0 → bitstruct-8.22.2}/docs/conf.py +0 -0
  12. {bitstruct-8.22.0 → bitstruct-8.22.2}/docs/index.rst +0 -0
  13. {bitstruct-8.22.0 → bitstruct-8.22.2}/docs/make.bat +0 -0
  14. {bitstruct-8.22.0 → bitstruct-8.22.2}/pyproject.toml +0 -0
  15. {bitstruct-8.22.0 → bitstruct-8.22.2}/setup.cfg +0 -0
  16. {bitstruct-8.22.0 → bitstruct-8.22.2}/setup.py +0 -0
  17. {bitstruct-8.22.0 → bitstruct-8.22.2}/src/bitstruct/bitstream.c +0 -0
  18. {bitstruct-8.22.0 → bitstruct-8.22.2}/src/bitstruct/bitstream.h +0 -0
  19. {bitstruct-8.22.0 → bitstruct-8.22.2}/src/bitstruct.egg-info/SOURCES.txt +0 -0
  20. {bitstruct-8.22.0 → bitstruct-8.22.2}/src/bitstruct.egg-info/dependency_links.txt +0 -0
  21. {bitstruct-8.22.0 → bitstruct-8.22.2}/src/bitstruct.egg-info/top_level.txt +0 -0
  22. {bitstruct-8.22.0 → bitstruct-8.22.2}/tests/__init__.py +0 -0
  23. {bitstruct-8.22.0 → bitstruct-8.22.2}/tests/test_bitstruct.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bitstruct
3
- Version: 8.22.0
3
+ Version: 8.22.2
4
4
  Summary: This module performs conversions between Python values and C bit field structs represented as Python byte strings.
5
5
  Author: Ilya Petukhov
6
6
  Author-email: Erik Moqvist <erik.moqvist@gmail.com>
@@ -1,4 +1,4 @@
1
- __version__ = '8.22.0'
1
+ __version__ = '8.22.2'
2
2
 
3
3
  import binascii
4
4
  import re
@@ -430,11 +430,11 @@ static void pack_float_16(struct bitstream_writer_t *self_p,
430
430
  #if PY_VERSION_HEX >= 0x030B00A7
431
431
  PyFloat_Pack2(PyFloat_AsDouble(value_p),
432
432
  (char*)&buf[0],
433
- PY_BIG_ENDIAN);
433
+ 0);
434
434
  #else
435
435
  _PyFloat_Pack2(PyFloat_AsDouble(value_p),
436
436
  &buf[0],
437
- PY_BIG_ENDIAN);
437
+ 0);
438
438
  #endif
439
439
  bitstream_writer_write_bytes(self_p, &buf[0], sizeof(buf));
440
440
  }
@@ -447,9 +447,9 @@ static PyObject *unpack_float_16(struct bitstream_reader_t *self_p,
447
447
 
448
448
  bitstream_reader_read_bytes(self_p, &buf[0], sizeof(buf));
449
449
  #if PY_VERSION_HEX >= 0x030B00A7
450
- value = PyFloat_Unpack2((const char*)&buf[0], PY_BIG_ENDIAN);
450
+ value = PyFloat_Unpack2((const char*)&buf[0], 0);
451
451
  #else
452
- value = _PyFloat_Unpack2(&buf[0], PY_BIG_ENDIAN);
452
+ value = _PyFloat_Unpack2(&buf[0], 0);
453
453
  #endif
454
454
 
455
455
  return (PyFloat_FromDouble(value));
@@ -925,6 +925,13 @@ static struct info_t *parse_format(PyObject *format_obj_p)
925
925
  return (NULL);
926
926
  }
927
927
 
928
+ if (number_of_bits > (INT_MAX - info_p->number_of_bits)) {
929
+ PyErr_SetString(PyExc_ValueError, "Format too long.");
930
+ PyMem_RawFree(info_p);
931
+
932
+ return (NULL);
933
+ }
934
+
928
935
  info_p->number_of_bits += number_of_bits;
929
936
  }
930
937
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bitstruct
3
- Version: 8.22.0
3
+ Version: 8.22.2
4
4
  Summary: This module performs conversions between Python values and C bit field structs represented as Python byte strings.
5
5
  Author: Ilya Petukhov
6
6
  Author-email: Erik Moqvist <erik.moqvist@gmail.com>
@@ -253,6 +253,12 @@ class CTest(unittest.TestCase):
253
253
  size = calcsize('b1s6u7u9P1t8')
254
254
  self.assertEqual(size, 32)
255
255
 
256
+ # The total number of bits does not fit in an int.
257
+ with self.assertRaises(ValueError) as cm:
258
+ calcsize('p214748369' * 20)
259
+
260
+ self.assertEqual(str(cm.exception), 'Format too long.')
261
+
256
262
  def test_compiled_calcsize(self):
257
263
  """Calculate size.
258
264
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes