bitarray 3.12.3__tar.gz → 3.12.4__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 (26) hide show
  1. {bitarray-3.12.3 → bitarray-3.12.4}/PKG-INFO +5 -5
  2. {bitarray-3.12.3 → bitarray-3.12.4}/README.rst +3 -3
  3. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/_bitarray.c +28 -13
  4. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/_util.c +6 -3
  5. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/bitarray.h +3 -2
  6. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/test_bitarray.py +2 -1
  7. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/test_util.py +71 -65
  8. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray.egg-info/PKG-INFO +5 -5
  9. {bitarray-3.12.3 → bitarray-3.12.4}/setup.py +11 -1
  10. {bitarray-3.12.3 → bitarray-3.12.4}/LICENSE +0 -0
  11. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/__init__.py +0 -0
  12. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/__init__.pyi +0 -0
  13. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/bitfields.py +0 -0
  14. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/py.typed +0 -0
  15. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/pythoncapi_compat.h +0 -0
  16. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/test_281.pickle +0 -0
  17. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/test_bitfields.py +0 -0
  18. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/test_free_threading.py +0 -0
  19. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/util.py +0 -0
  20. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray/util.pyi +0 -0
  21. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray.egg-info/SOURCES.txt +0 -0
  22. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray.egg-info/dependency_links.txt +0 -0
  23. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray.egg-info/not-zip-safe +0 -0
  24. {bitarray-3.12.3 → bitarray-3.12.4}/bitarray.egg-info/top_level.txt +0 -0
  25. {bitarray-3.12.3 → bitarray-3.12.4}/pyproject.toml +0 -0
  26. {bitarray-3.12.3 → bitarray-3.12.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bitarray
3
- Version: 3.12.3
3
+ Version: 3.12.4
4
4
  Summary: efficient arrays of booleans -- C extension
5
5
  Home-page: https://github.com/ilanschnell/bitarray
6
6
  Author: Ilan Schnell
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3.13
21
21
  Classifier: Programming Language :: Python :: 3.14
22
22
  Classifier: Programming Language :: Python :: 3.15
23
- Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
23
+ Classifier: Programming Language :: Python :: Free Threading :: 3 - Stable
24
24
  Classifier: Topic :: Utilities
25
25
  Requires-Python: >=3.7
26
26
  License-File: LICENSE
@@ -57,7 +57,7 @@ Key features
57
57
  their in-place versions ``&=``, ``|=``, ``^=``, ``<<=``, ``>>=``).
58
58
  * `Free-threading support <https://github.com/ilanschnell/bitarray/blob/master/doc/free_threading.rst>`__
59
59
  (for GIL-disabled CPython 3.14 and later)
60
- * Written to `support all platforms supported by CPython and PyPy <https://github.com/ilanschnell/bitarray/blob/master/doc/platforms.rst>`__.
60
+ * Written to support all `platforms supported <https://github.com/ilanschnell/bitarray/blob/master/doc/platforms.rst>`__ by CPython and PyPy.
61
61
  * Fast methods for encoding and decoding variable-length
62
62
  `prefix codes <https://github.com/ilanschnell/bitarray/blob/master/doc/prefix_codes.rst>`__.
63
63
  * Bitarray objects support the `buffer protocol <https://github.com/ilanschnell/bitarray/blob/master/doc/buffer.rst>`__
@@ -102,7 +102,7 @@ Once you have installed the package, you may want to test it:
102
102
  $ python -c 'import bitarray; bitarray.test()'
103
103
  bitarray is installed in: /Users/ilan/bitarray/bitarray
104
104
  sys.prefix: /Users/ilan/miniforge
105
- bitarray version: 3.12.3
105
+ bitarray version: 3.12.4
106
106
  platform.machine(): arm64
107
107
  platform.platform(): macOS-14.3-arm64-arm-64bit-Mach-O
108
108
  sys.platform: darwin
@@ -314,7 +314,7 @@ and can therefore be used as a dictionary key:
314
314
  Reference
315
315
  =========
316
316
 
317
- bitarray version: 3.12.3 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
317
+ bitarray version: 3.12.4 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
318
318
 
319
319
  In the following, ``item`` and ``value`` are usually a single bit -
320
320
  an integer 0 or 1.
@@ -21,7 +21,7 @@ Key features
21
21
  their in-place versions ``&=``, ``|=``, ``^=``, ``<<=``, ``>>=``).
22
22
  * `Free-threading support <https://github.com/ilanschnell/bitarray/blob/master/doc/free_threading.rst>`__
23
23
  (for GIL-disabled CPython 3.14 and later)
24
- * Written to `support all platforms supported by CPython and PyPy <https://github.com/ilanschnell/bitarray/blob/master/doc/platforms.rst>`__.
24
+ * Written to support all `platforms supported <https://github.com/ilanschnell/bitarray/blob/master/doc/platforms.rst>`__ by CPython and PyPy.
25
25
  * Fast methods for encoding and decoding variable-length
26
26
  `prefix codes <https://github.com/ilanschnell/bitarray/blob/master/doc/prefix_codes.rst>`__.
27
27
  * Bitarray objects support the `buffer protocol <https://github.com/ilanschnell/bitarray/blob/master/doc/buffer.rst>`__
@@ -66,7 +66,7 @@ Once you have installed the package, you may want to test it:
66
66
  $ python -c 'import bitarray; bitarray.test()'
67
67
  bitarray is installed in: /Users/ilan/bitarray/bitarray
68
68
  sys.prefix: /Users/ilan/miniforge
69
- bitarray version: 3.12.3
69
+ bitarray version: 3.12.4
70
70
  platform.machine(): arm64
71
71
  platform.platform(): macOS-14.3-arm64-arm-64bit-Mach-O
72
72
  sys.platform: darwin
@@ -278,7 +278,7 @@ and can therefore be used as a dictionary key:
278
278
  Reference
279
279
  =========
280
280
 
281
- bitarray version: 3.12.3 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
281
+ bitarray version: 3.12.4 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
282
282
 
283
283
  In the following, ``item`` and ``value`` are usually a single bit -
284
284
  an integer 0 or 1.
@@ -5394,48 +5394,63 @@ PyInit__bitarray(void)
5394
5394
  reverse_trans = {0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, ..., 0xff} */
5395
5395
  setup_table(reverse_trans, 'r');
5396
5396
 
5397
- if ((m = PyModule_Create(&moduledef)) == NULL)
5397
+ m = PyModule_Create(&moduledef);
5398
+ if (m == NULL)
5398
5399
  return NULL;
5399
5400
 
5400
5401
  #ifdef Py_GIL_DISABLED
5401
5402
  if (PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED) < 0)
5402
- return NULL;
5403
+ goto error;
5403
5404
  #endif
5404
5405
 
5405
5406
  if (PyType_Ready(&Bitarray_Type) < 0)
5406
- return NULL;
5407
+ goto error;
5407
5408
  Py_SET_TYPE(&Bitarray_Type, &PyType_Type);
5408
5409
  Py_INCREF((PyObject *) &Bitarray_Type);
5409
- PyModule_AddObject(m, "bitarray", (PyObject *) &Bitarray_Type);
5410
+ if (PyModule_AddObject(m, "bitarray", (PyObject *) &Bitarray_Type) < 0) {
5411
+ Py_DECREF((PyObject *) &Bitarray_Type);
5412
+ goto error;
5413
+ }
5410
5414
 
5411
5415
  if (add_capsule(m) < 0)
5412
- return NULL;
5416
+ goto error;
5413
5417
 
5414
5418
  if (register_abc() < 0)
5415
- return NULL;
5419
+ goto error;
5416
5420
 
5417
5421
  if (PyType_Ready(&DecodeTree_Type) < 0)
5418
- return NULL;
5422
+ goto error;
5419
5423
  Py_SET_TYPE(&DecodeTree_Type, &PyType_Type);
5420
5424
  Py_INCREF((PyObject *) &DecodeTree_Type);
5421
- PyModule_AddObject(m, "decodetree", (PyObject *) &DecodeTree_Type);
5425
+ if (PyModule_AddObject(m, "decodetree",
5426
+ (PyObject *) &DecodeTree_Type) < 0) {
5427
+ Py_DECREF((PyObject *) &DecodeTree_Type);
5428
+ goto error;
5429
+ }
5422
5430
 
5423
5431
  if (PyType_Ready(&DecodeIter_Type) < 0)
5424
- return NULL;
5432
+ goto error;
5425
5433
  Py_SET_TYPE(&DecodeIter_Type, &PyType_Type);
5426
5434
  Py_INCREF((PyObject *) &DecodeIter_Type);
5427
- PyModule_AddObject(m, "decodeiterator", (PyObject *) &DecodeIter_Type);
5435
+ if (PyModule_AddObject(m, "decodeiterator",
5436
+ (PyObject *) &DecodeIter_Type) < 0) {
5437
+ Py_DECREF((PyObject *) &DecodeIter_Type);
5438
+ goto error;
5439
+ }
5428
5440
 
5429
5441
  if (PyType_Ready(&BitarrayIter_Type) < 0)
5430
- return NULL;
5442
+ goto error;
5431
5443
  Py_SET_TYPE(&BitarrayIter_Type, &PyType_Type);
5432
5444
 
5433
5445
  if (PyType_Ready(&SearchIter_Type) < 0)
5434
- return NULL;
5446
+ goto error;
5435
5447
  Py_SET_TYPE(&SearchIter_Type, &PyType_Type);
5436
5448
 
5437
5449
  if (PyModule_AddStringMacro(m, BITARRAY_VERSION) < 0)
5438
- return NULL;
5450
+ goto error;
5439
5451
 
5440
5452
  return m;
5453
+ error:
5454
+ Py_DECREF(m);
5455
+ return NULL;
5441
5456
  }
@@ -2883,17 +2883,20 @@ PyInit__util(void)
2883
2883
 
2884
2884
  #ifdef Py_GIL_DISABLED
2885
2885
  if (PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED) < 0)
2886
- return NULL;
2886
+ goto error;
2887
2887
  #endif
2888
2888
 
2889
2889
  if (PyType_Ready(&CHDI_Type) < 0)
2890
- return NULL;
2890
+ goto error;
2891
2891
  Py_SET_TYPE(&CHDI_Type, &PyType_Type);
2892
2892
 
2893
2893
  #ifndef NDEBUG /* expose segment size in debug mode for testing */
2894
2894
  if (PyModule_AddIntConstant(m, "_SEGSIZE", SEGSIZE) < 0)
2895
- return NULL;
2895
+ goto error;
2896
2896
  #endif
2897
2897
 
2898
2898
  return m;
2899
+ error:
2900
+ Py_DECREF(m);
2901
+ return NULL;
2899
2902
  }
@@ -4,7 +4,7 @@
4
4
 
5
5
  Author: Ilan Schnell
6
6
  */
7
- #define BITARRAY_VERSION "3.12.3"
7
+ #define BITARRAY_VERSION "3.12.4"
8
8
 
9
9
  #ifdef STDC_HEADERS
10
10
  # include <stddef.h>
@@ -68,7 +68,8 @@ typedef struct {
68
68
  #define WBUFF(self) ((uint64_t *) (self)->ob_item)
69
69
 
70
70
  /* assert that .nbits is in agreement with .ob_size */
71
- #define assert_nbits(self) assert(BYTES((self)->nbits) == Py_SIZE(self))
71
+ #define assert_nbits(self) assert((Py_ssize_t) BYTES((self)->nbits) == \
72
+ Py_SIZE(self))
72
73
 
73
74
  /* ------------ low level access to bits in bitarrayobject ------------- */
74
75
 
@@ -3701,7 +3701,8 @@ class ByteReverseTests(unittest.TestCase, Util):
3701
3701
  t = bitarray(bytearray(range(256)), choice(ENDIANS))
3702
3702
  t.bytereverse()
3703
3703
  table = t.tobytes() # translation table
3704
- self.assertEqual(table[:9], b'\x00\x80\x40\xc0\x20\xa0\x60\xe0\x10')
3704
+ self.assertEqual(table[:9],
3705
+ bytes.fromhex("00 80 40 c0 20 a0 60 e0 10"))
3705
3706
 
3706
3707
  for n in range(100):
3707
3708
  a = urandom_2(8 * n)
@@ -1849,16 +1849,17 @@ class SC_Util:
1849
1849
  class SC_Tests(unittest.TestCase, Util, SC_Util):
1850
1850
 
1851
1851
  def test_explicit(self):
1852
- for b, bits, endian in [
1853
- (b'\x00\0', '', 'little'),
1854
- (b'\x01\x03\x01\x03\0', '110', 'little'),
1855
- (b'\x01\x07\x01\x40\0', '0000001', 'little'),
1856
- (b'\x11\x07\x01\x02\0', '0000001', 'big'),
1857
- (b'\x01\x10\x02\xf0\x0f\0', '00001111 11110000', 'little'),
1858
- (b'\x11\x10\xa1\x0c\0', '00000000 00001000', 'big'),
1859
- (b'\x11\x09\xa1\x08\0', '00000000 1', 'big'),
1860
- (b'\x01g\xa4abde\0', 97 * '0' + '110110', 'little'),
1852
+ for hexstr, bits, endian in [
1853
+ ('00 00', '', 'little'),
1854
+ ('01 03 01 03 00', '110', 'little'),
1855
+ ('01 07 01 40 00', '0000001', 'little'),
1856
+ ('11 07 01 02 00', '0000001', 'big'),
1857
+ ('01 10 02 f0 0f 00', '00001111 11110000', 'little'),
1858
+ ('11 10 a1 0c 00', '00000000 00001000', 'big'),
1859
+ ('11 09 a1 08 00', '00000000 1', 'big'),
1860
+ ('01 67 a4 61 62 64 65 00', 97 * '0' + '110110', 'little'),
1861
1861
  ]:
1862
+ b = bytes.fromhex(hexstr)
1862
1863
  a = bitarray(bits, endian)
1863
1864
  self.assertEqual(sc_encode(a), b)
1864
1865
  self.assertEQUAL(sc_decode(b), a)
@@ -1880,13 +1881,13 @@ class SC_Tests(unittest.TestCase, Util, SC_Util):
1880
1881
  for a in bitarray('1', 'big'), frozenbitarray('1', 'big'):
1881
1882
  b = sc_encode(a)
1882
1883
  self.assertIs(type(b), bytes)
1883
- self.assertEqual(b, b'\x11\x01\x01\x80\0')
1884
+ self.assertEqual(b, bytes.fromhex("11 01 01 80 00"))
1884
1885
 
1885
1886
  for a in None, [], 0, 123, b'', b'\x00', 3.14:
1886
1887
  self.assertRaises(TypeError, sc_encode, a)
1887
1888
 
1888
1889
  def test_decode_stat_types(self):
1889
- blob = b'\x11\x03\x01\x20\0'
1890
+ blob = bytes.fromhex("11 03 01 20 00")
1890
1891
  for b in blob, bytearray(blob), list(blob), array.array('B', blob):
1891
1892
  a = sc_decode(b)
1892
1893
  self.assertIs(type(a), bitarray)
@@ -1905,17 +1906,18 @@ class SC_Tests(unittest.TestCase, Util, SC_Util):
1905
1906
  self.assertTrue(all(type(n) is int for n in blocks))
1906
1907
 
1907
1908
  def test_zero_explicit(self):
1908
- for blob, blocks, nbits in [
1909
+ for hexstr, blocks, nbits in [
1909
1910
  # empty bitarray
1910
- (b"\x00\0", [0, 0, 0, 0, 0], 0),
1911
- (b"\x02\x00\x00\xa0\xc2\x00\xc3\x00\xc4\x00\xa0\0",
1912
- [0, 2, 1, 1, 1], 0),
1911
+ ("00 00", [0, 0, 0, 0, 0], 0),
1912
+ ("02 00 00 a0 c2 00 c3 00 c4 00 a0 00",
1913
+ [0, 2, 1, 1, 1], 0),
1913
1914
  # zero bitarray with length 8
1914
- (b"\x01\x08\0", [0, 0, 0, 0, 0], 8),
1915
- (b"\x03\x08\x00\x00\0", [0, 0, 0, 0, 0], 8),
1916
- (b"\x01\x08\x01\x00\xa0\xc2\x00\xc3\x00\xc4\x00\xa0\xa0\0",
1917
- [1, 3, 1, 1, 1], 8),
1915
+ ("01 08 00", [0, 0, 0, 0, 0], 8),
1916
+ ("03 08 00 00 00", [0, 0, 0, 0, 0], 8),
1917
+ ("01 08 01 00 a0 c2 00 c3 00 c4 00 a0 a0 00",
1918
+ [1, 3, 1, 1, 1], 8),
1918
1919
  ]:
1920
+ blob = bytes.fromhex(hexstr)
1919
1921
  it = iter(blob)
1920
1922
  a = sc_decode(it)
1921
1923
  self.assertRaises(StopIteration, next, it)
@@ -2003,58 +2005,59 @@ class SC_Tests(unittest.TestCase, Util, SC_Util):
2003
2005
  self.assertRaisesMessage(
2004
2006
  ValueError,
2005
2007
  "read 4 bytes got negative value: -2147483648",
2006
- sc_decode, b'\x04\x00\x00\x00\x80')
2008
+ sc_decode, bytes.fromhex('04 00 00 00 80'))
2007
2009
 
2008
2010
  def test_decode_errors(self):
2009
2011
  # too many raw bytes
2010
2012
  self.assertRaisesMessage(
2011
2013
  ValueError, "decode error (raw): 0 + 2 > 1",
2012
- sc_decode, b"\x01\x05\x02\xff\xff\0")
2014
+ sc_decode, bytes.fromhex("01 05 02 ff ff 00"))
2013
2015
  self.assertRaisesMessage(
2014
2016
  ValueError, "decode error (raw): 32 + 3 > 34",
2015
- sc_decode, b"\x02\x0f\x01\xa0\x03\xff\xff\xff\0")
2017
+ sc_decode, bytes.fromhex("02 0f 01 a0 03 ff ff ff 00"))
2016
2018
 
2017
2019
  # sparse index too high
2018
2020
  self.assertRaisesMessage(
2019
2021
  ValueError, "decode error (n=1): 128 >= 128",
2020
- sc_decode, b"\x01\x80\xa1\x80\0")
2022
+ sc_decode, bytes.fromhex("01 80 a1 80 00"))
2021
2023
  self.assertRaisesMessage(
2022
2024
  ValueError, "decode error (n=2): 512 >= 512",
2023
- sc_decode, b"\x02\x00\x02\xc2\x01\x00\x02\0")
2025
+ sc_decode, bytes.fromhex("02 00 02 c2 01 00 02 00"))
2024
2026
  self.assertRaisesMessage(
2025
2027
  ValueError, "decode error (n=3): 32768 >= 32768",
2026
- sc_decode, b"\x02\x00\x80\xc3\x01\x00\x80\x00\0")
2028
+ sc_decode, bytes.fromhex("02 00 80 c3 01 00 80 00 00"))
2027
2029
 
2028
2030
  msg = {4: "read 4 bytes got negative value: -2147483648",
2029
2031
  8: "decode error (n=4): 2147483648 >= 16"}
2030
2032
  self.assertRaisesMessage(
2031
2033
  ValueError, msg[PTRSIZE],
2032
- sc_decode, b"\x01\x10\xc4\x01\x00\x00\x00\x80\0")
2034
+ sc_decode, bytes.fromhex("01 10 c4 01 00 00 00 80 00"))
2033
2035
 
2034
2036
  msg = {4: "read 4 bytes got negative value: -1",
2035
2037
  8: "decode error (n=4): 4294967295 >= 16"}
2036
2038
  self.assertRaisesMessage(
2037
2039
  ValueError, msg[PTRSIZE],
2038
- sc_decode, b"\x01\x10\xc4\x01\xff\xff\xff\xff\0")
2040
+ sc_decode, bytes.fromhex("01 10 c4 01 ff ff ff ff 00"))
2039
2041
 
2040
2042
  def test_stop_iteration(self):
2041
- for stream in [b'', b'\x00', b'\x01', b'\x02\x77',
2042
- b'\x01\x04\x01', b'\x01\x04\xa1', b'\x01\x04\xa0']:
2043
+ for hexstr in ['', '00', '01', '02 77',
2044
+ '01 04 01', '01 04 a1', '01 04 a0']:
2043
2045
  for f in sc_decode, sc_stat:
2044
- self.assertRaises(StopIteration, f, stream)
2046
+ self.assertRaises(StopIteration, f, bytes.fromhex(hexstr))
2045
2047
 
2046
2048
  def test_decode_ambiguity(self):
2047
- for n, blob in [
2049
+ for n, hexstr in [
2048
2050
  # raw:
2049
- (0, b'\x11\x03\x01\x20\0'), # this is what sc_encode gives us
2050
- (0, b'\x11\x03\x01\x3f\0'), # set the pad bits to 1
2051
- (0, b'\x12\x03\x00\x01\x20\0'), # header has redundant zeros
2051
+ (0, '11 03 01 20 00'), # this is what sc_encode gives us
2052
+ (0, '11 03 01 3f 00'), # set the pad bits to 1
2053
+ (0, '12 03 00 01 20 00'), # header has redundant zeros
2052
2054
  # sparse:
2053
- (1, b'\x11\x03\xa1\x02\0'),
2054
- (2, b'\x11\x03\xc2\x01\x02\x00\0'),
2055
- (3, b'\x11\x03\xc3\x01\x02\x00\x00\0'),
2056
- (4, b'\x11\x03\xc4\x01\x02\x00\x00\x00\0'),
2055
+ (1, '11 03 a1 02 00'),
2056
+ (2, '11 03 c2 01 02 00 00'),
2057
+ (3, '11 03 c3 01 02 00 00 00'),
2058
+ (4, '11 03 c4 01 02 00 00 00 00'),
2057
2059
  ]:
2060
+ blob = bytes.fromhex(hexstr)
2058
2061
  a = sc_decode(blob)
2059
2062
  self.assertEqual(a.to01(), '001')
2060
2063
  stat = sc_stat(blob)
@@ -2212,18 +2215,19 @@ class SC_Tests(unittest.TestCase, Util, SC_Util):
2212
2215
  class VL_Tests(unittest.TestCase, Util):
2213
2216
 
2214
2217
  def test_explicit(self):
2215
- for blob, s in [
2216
- (b'\x40', ''),
2217
- (b'\x30', '0'),
2218
- (b'\x38', '1'),
2219
- (b'\x00', '0000'),
2220
- (b'\x01', '0001'),
2221
- (b'\xd3\x20', '001101'),
2222
- (b'\xe0\x40', '0000 1'),
2223
- (b'\x90\x02', '0000 000001'),
2224
- (b'\xb5\xa7\x18', '0101 0100111 0011'),
2225
- (b'\x95\xb7\x1c', '0101 0110111 001110'),
2218
+ for hexstr, s in [
2219
+ ('40', ''),
2220
+ ('30', '0'),
2221
+ ('38', '1'),
2222
+ ('00', '0000'),
2223
+ ('01', '0001'),
2224
+ ('d3 20', '001101'),
2225
+ ('e0 40', '0000 1'),
2226
+ ('90 02', '0000 000001'),
2227
+ ('b5 a7 18', '0101 0100111 0011'),
2228
+ ('95 b7 1c', '0101 0110111 001110'),
2226
2229
  ]:
2230
+ blob = bytes.fromhex(hexstr)
2227
2231
  a = bitarray(s)
2228
2232
  self.assertEqual(vl_encode(a), blob)
2229
2233
  c = vl_decode(blob)
@@ -2286,7 +2290,7 @@ class VL_Tests(unittest.TestCase, Util):
2286
2290
  self.assertEqual(vl_decode(s), bitarray('111'))
2287
2291
 
2288
2292
  def test_decode_stream(self):
2289
- stream = iter(b'\x40\x30\x38\x40\x2c\xe0\x40\xd3\x20')
2293
+ stream = iter(bytes.fromhex('40 30 38 40 2c e0 40 d3 20'))
2290
2294
  for bits in '', '0', '1', '', '11', '0000 1', '0011 01':
2291
2295
  self.assertEqual(vl_decode(stream), bitarray(bits))
2292
2296
 
@@ -2690,15 +2694,16 @@ class MixedTests(unittest.TestCase, Util):
2690
2694
  class SerializationTests(unittest.TestCase, Util):
2691
2695
 
2692
2696
  def test_explicit(self):
2693
- for blob, endian, bits in [
2694
- (b'\x00', 'little', ''),
2695
- (b'\x07\x01', 'little', '1'),
2696
- (b'\x17\x80', 'big', '1'),
2697
- (b'\x13\xf8', 'big', '11111'),
2698
- (b'\x00\x0f', 'little', '11110000'),
2699
- (b'\x10\xf0', 'big', '11110000'),
2700
- (b'\x12\x87\xd8', 'big', '10000111 110110')
2697
+ for hexstr, endian, bits in [
2698
+ ('00', 'little', ''),
2699
+ ('07 01', 'little', '1'),
2700
+ ('17 80', 'big', '1'),
2701
+ ('13 f8', 'big', '11111'),
2702
+ ('00 0f', 'little', '11110000'),
2703
+ ('10 f0', 'big', '11110000'),
2704
+ ('12 87 d8', 'big', '10000111 110110')
2701
2705
  ]:
2706
+ blob = bytes.fromhex(hexstr)
2702
2707
  a = bitarray(bits, endian)
2703
2708
  s = serialize(a)
2704
2709
  self.assertEqual(blob, s)
@@ -2758,14 +2763,15 @@ class SerializationTests(unittest.TestCase, Util):
2758
2763
  check_msg(b)
2759
2764
 
2760
2765
  def test_padbits_ignored(self):
2761
- for blob, endian in [
2762
- (b'\x07\x01', 'little'),
2763
- (b'\x07\x03', 'little'),
2764
- (b'\x07\xff', 'little'),
2765
- (b'\x17\x80', 'big'),
2766
- (b'\x17\xc0', 'big'),
2767
- (b'\x17\xff', 'big'),
2766
+ for hexstr, endian in [
2767
+ ('07 01', 'little'),
2768
+ ('07 03', 'little'),
2769
+ ('07 ff', 'little'),
2770
+ ('17 80', 'big'),
2771
+ ('17 c0', 'big'),
2772
+ ('17 ff', 'big'),
2768
2773
  ]:
2774
+ blob = bytes.fromhex(hexstr)
2769
2775
  a = deserialize(blob)
2770
2776
  self.assertEqual(a.to01(), '1')
2771
2777
  self.assertEqual(a.endian, endian)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bitarray
3
- Version: 3.12.3
3
+ Version: 3.12.4
4
4
  Summary: efficient arrays of booleans -- C extension
5
5
  Home-page: https://github.com/ilanschnell/bitarray
6
6
  Author: Ilan Schnell
@@ -20,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Programming Language :: Python :: 3.13
21
21
  Classifier: Programming Language :: Python :: 3.14
22
22
  Classifier: Programming Language :: Python :: 3.15
23
- Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
23
+ Classifier: Programming Language :: Python :: Free Threading :: 3 - Stable
24
24
  Classifier: Topic :: Utilities
25
25
  Requires-Python: >=3.7
26
26
  License-File: LICENSE
@@ -57,7 +57,7 @@ Key features
57
57
  their in-place versions ``&=``, ``|=``, ``^=``, ``<<=``, ``>>=``).
58
58
  * `Free-threading support <https://github.com/ilanschnell/bitarray/blob/master/doc/free_threading.rst>`__
59
59
  (for GIL-disabled CPython 3.14 and later)
60
- * Written to `support all platforms supported by CPython and PyPy <https://github.com/ilanschnell/bitarray/blob/master/doc/platforms.rst>`__.
60
+ * Written to support all `platforms supported <https://github.com/ilanschnell/bitarray/blob/master/doc/platforms.rst>`__ by CPython and PyPy.
61
61
  * Fast methods for encoding and decoding variable-length
62
62
  `prefix codes <https://github.com/ilanschnell/bitarray/blob/master/doc/prefix_codes.rst>`__.
63
63
  * Bitarray objects support the `buffer protocol <https://github.com/ilanschnell/bitarray/blob/master/doc/buffer.rst>`__
@@ -102,7 +102,7 @@ Once you have installed the package, you may want to test it:
102
102
  $ python -c 'import bitarray; bitarray.test()'
103
103
  bitarray is installed in: /Users/ilan/bitarray/bitarray
104
104
  sys.prefix: /Users/ilan/miniforge
105
- bitarray version: 3.12.3
105
+ bitarray version: 3.12.4
106
106
  platform.machine(): arm64
107
107
  platform.platform(): macOS-14.3-arm64-arm-64bit-Mach-O
108
108
  sys.platform: darwin
@@ -314,7 +314,7 @@ and can therefore be used as a dictionary key:
314
314
  Reference
315
315
  =========
316
316
 
317
- bitarray version: 3.12.3 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
317
+ bitarray version: 3.12.4 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
318
318
 
319
319
  In the following, ``item`` and ``value`` are usually a single bit -
320
320
  an integer 0 or 1.
@@ -1,6 +1,7 @@
1
1
  import re
2
2
  import sys
3
3
  import platform
4
+ from sysconfig import get_config_var
4
5
 
5
6
 
6
7
  if "test" in sys.argv:
@@ -23,7 +24,15 @@ data = open('bitarray/bitarray.h').read()
23
24
  kwds['version'] = pat.search(data).group(1)
24
25
 
25
26
  macros = []
27
+ if get_config_var("Py_GIL_DISABLED") in (1, "1"):
28
+ macros.append(("Py_GIL_DISABLED", "1"))
29
+
26
30
  if platform.python_implementation() == 'PyPy':
31
+ min_ver = (7, 3, 23)
32
+ pypy_ver = sys.pypy_version_info[:3]
33
+ if pypy_ver < min_ver:
34
+ sys.exit("Not supported: PyPy %s or higher required, current PyPy "
35
+ "version %s" % ("%d.%d.%d" % min_ver, "%d.%d.%d" % pypy_ver))
27
36
  macros.append(("PY_LITTLE_ENDIAN", str(int(sys.byteorder == 'little'))))
28
37
  macros.append(("PY_BIG_ENDIAN", str(int(sys.byteorder == 'big'))))
29
38
 
@@ -49,7 +58,7 @@ setup(
49
58
  "Programming Language :: Python :: 3.13",
50
59
  "Programming Language :: Python :: 3.14",
51
60
  "Programming Language :: Python :: 3.15",
52
- "Programming Language :: Python :: Free Threading :: 2 - Beta",
61
+ "Programming Language :: Python :: Free Threading :: 3 - Stable",
53
62
  "Topic :: Utilities",
54
63
  ],
55
64
  description = "efficient arrays of booleans -- C extension",
@@ -61,6 +70,7 @@ setup(
61
70
  define_macros = macros,
62
71
  sources = ["bitarray/_bitarray.c"]),
63
72
  Extension(name = "bitarray._util",
73
+ define_macros = macros,
64
74
  sources = ["bitarray/_util.c"])],
65
75
  zip_safe = False,
66
76
  **kwds
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes