bitarray 3.8.0__tar.gz → 3.8.1__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.
- {bitarray-3.8.0 → bitarray-3.8.1}/LICENSE +1 -1
- {bitarray-3.8.0 → bitarray-3.8.1}/PKG-INFO +4 -4
- {bitarray-3.8.0 → bitarray-3.8.1}/README.rst +3 -3
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/__init__.py +1 -1
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/__init__.pyi +1 -1
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/_bitarray.c +36 -10
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/_util.c +13 -6
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/bitarray.h +2 -2
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/test_bitarray.py +36 -9
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/test_util.py +6 -3
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/util.py +1 -1
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/util.pyi +1 -1
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray.egg-info/PKG-INFO +4 -4
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/py.typed +0 -0
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/pythoncapi_compat.h +0 -0
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray/test_281.pickle +0 -0
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray.egg-info/SOURCES.txt +0 -0
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray.egg-info/dependency_links.txt +0 -0
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray.egg-info/not-zip-safe +0 -0
- {bitarray-3.8.0 → bitarray-3.8.1}/bitarray.egg-info/top_level.txt +0 -0
- {bitarray-3.8.0 → bitarray-3.8.1}/pyproject.toml +0 -0
- {bitarray-3.8.0 → bitarray-3.8.1}/setup.cfg +0 -0
- {bitarray-3.8.0 → bitarray-3.8.1}/setup.py +0 -0
|
@@ -11,7 +11,7 @@ license to reproduce, analyze, test, perform and/or display publicly,
|
|
|
11
11
|
prepare derivative works, distribute, and otherwise use bitarray
|
|
12
12
|
alone or in any derivative version, provided, however, that Ilan Schnell's
|
|
13
13
|
License Agreement and Ilan Schnell's notice of copyright, i.e., "Copyright (c)
|
|
14
|
-
2008 -
|
|
14
|
+
2008 - 2026 Ilan Schnell; All Rights Reserved" are retained in bitarray
|
|
15
15
|
alone or in any derivative version prepared by Licensee.
|
|
16
16
|
|
|
17
17
|
3. In the event Licensee prepares a derivative work that is based on
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bitarray
|
|
3
|
-
Version: 3.8.
|
|
3
|
+
Version: 3.8.1
|
|
4
4
|
Summary: efficient arrays of booleans -- C extension
|
|
5
5
|
Home-page: https://github.com/ilanschnell/bitarray
|
|
6
6
|
Author: Ilan Schnell
|
|
@@ -91,7 +91,7 @@ Once you have installed the package, you may want to test it:
|
|
|
91
91
|
|
|
92
92
|
$ python -c 'import bitarray; bitarray.test()'
|
|
93
93
|
bitarray is installed in: /Users/ilan/bitarray/bitarray
|
|
94
|
-
bitarray version: 3.8.
|
|
94
|
+
bitarray version: 3.8.1
|
|
95
95
|
sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
|
|
96
96
|
sys.prefix: /Users/ilan/miniforge
|
|
97
97
|
pointer size: 64 bit
|
|
@@ -107,7 +107,7 @@ Once you have installed the package, you may want to test it:
|
|
|
107
107
|
.........................................................................
|
|
108
108
|
................................................................
|
|
109
109
|
----------------------------------------------------------------------
|
|
110
|
-
Ran
|
|
110
|
+
Ran 598 tests in 0.165s
|
|
111
111
|
|
|
112
112
|
OK
|
|
113
113
|
|
|
@@ -354,7 +354,7 @@ and can therefore be used as a dictionary key:
|
|
|
354
354
|
Reference
|
|
355
355
|
=========
|
|
356
356
|
|
|
357
|
-
bitarray version: 3.8.
|
|
357
|
+
bitarray version: 3.8.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
|
|
358
358
|
|
|
359
359
|
In the following, ``item`` and ``value`` are usually a single bit -
|
|
360
360
|
an integer 0 or 1.
|
|
@@ -57,7 +57,7 @@ Once you have installed the package, you may want to test it:
|
|
|
57
57
|
|
|
58
58
|
$ python -c 'import bitarray; bitarray.test()'
|
|
59
59
|
bitarray is installed in: /Users/ilan/bitarray/bitarray
|
|
60
|
-
bitarray version: 3.8.
|
|
60
|
+
bitarray version: 3.8.1
|
|
61
61
|
sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
|
|
62
62
|
sys.prefix: /Users/ilan/miniforge
|
|
63
63
|
pointer size: 64 bit
|
|
@@ -73,7 +73,7 @@ Once you have installed the package, you may want to test it:
|
|
|
73
73
|
.........................................................................
|
|
74
74
|
................................................................
|
|
75
75
|
----------------------------------------------------------------------
|
|
76
|
-
Ran
|
|
76
|
+
Ran 598 tests in 0.165s
|
|
77
77
|
|
|
78
78
|
OK
|
|
79
79
|
|
|
@@ -320,7 +320,7 @@ and can therefore be used as a dictionary key:
|
|
|
320
320
|
Reference
|
|
321
321
|
=========
|
|
322
322
|
|
|
323
|
-
bitarray version: 3.8.
|
|
323
|
+
bitarray version: 3.8.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
|
|
324
324
|
|
|
325
325
|
In the following, ``item`` and ``value`` are usually a single bit -
|
|
326
326
|
an integer 0 or 1.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2008 -
|
|
1
|
+
# Copyright (c) 2008 - 2026, Ilan Schnell; All Rights Reserved
|
|
2
2
|
"""
|
|
3
3
|
This package defines an object type which can efficiently represent
|
|
4
4
|
a bitarray. Bitarrays are sequence types and behave very much like lists.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2008 -
|
|
2
|
+
Copyright (c) 2008 - 2026, Ilan Schnell; All Rights Reserved
|
|
3
3
|
bitarray is published under the PSF license.
|
|
4
4
|
|
|
5
5
|
This file is the C part of the bitarray package.
|
|
@@ -96,6 +96,9 @@ resize(bitarrayobject *self, Py_ssize_t nbits)
|
|
|
96
96
|
assert(new_allocated >= newsize);
|
|
97
97
|
self->ob_item = PyMem_Realloc(self->ob_item, new_allocated);
|
|
98
98
|
if (self->ob_item == NULL) {
|
|
99
|
+
Py_SET_SIZE(self, 0);
|
|
100
|
+
self->allocated = 0;
|
|
101
|
+
self->nbits = 0;
|
|
99
102
|
PyErr_NoMemory();
|
|
100
103
|
return -1;
|
|
101
104
|
}
|
|
@@ -1028,7 +1031,7 @@ bitarray_buffer_info(bitarrayobject *self)
|
|
|
1028
1031
|
readonly = PyBool_FromLong(self->readonly);
|
|
1029
1032
|
imported = PyBool_FromLong(self->buffer ? 1 : 0);
|
|
1030
1033
|
if (address == NULL || readonly == NULL || imported == NULL)
|
|
1031
|
-
|
|
1034
|
+
goto error;
|
|
1032
1035
|
|
|
1033
1036
|
args = Py_BuildValue("OnsnnOOi",
|
|
1034
1037
|
address,
|
|
@@ -1039,12 +1042,21 @@ bitarray_buffer_info(bitarrayobject *self)
|
|
|
1039
1042
|
readonly,
|
|
1040
1043
|
imported,
|
|
1041
1044
|
self->ob_exports);
|
|
1045
|
+
if (args == NULL)
|
|
1046
|
+
goto error;
|
|
1047
|
+
|
|
1042
1048
|
Py_DECREF(address);
|
|
1043
1049
|
Py_DECREF(readonly);
|
|
1044
1050
|
Py_DECREF(imported);
|
|
1045
1051
|
res = PyObject_CallObject(info, args);
|
|
1046
1052
|
Py_DECREF(args);
|
|
1047
1053
|
return res;
|
|
1054
|
+
|
|
1055
|
+
error:
|
|
1056
|
+
Py_XDECREF(address);
|
|
1057
|
+
Py_XDECREF(readonly);
|
|
1058
|
+
Py_XDECREF(imported);
|
|
1059
|
+
return NULL;
|
|
1048
1060
|
}
|
|
1049
1061
|
|
|
1050
1062
|
PyDoc_STRVAR(buffer_info_doc,
|
|
@@ -1600,7 +1612,7 @@ extend_fread(bitarrayobject *self, PyObject *f, Py_ssize_t n)
|
|
|
1600
1612
|
ret = bitarray_frombytes(self, bytes);
|
|
1601
1613
|
Py_DECREF(bytes);
|
|
1602
1614
|
if (ret == NULL)
|
|
1603
|
-
|
|
1615
|
+
return -1;
|
|
1604
1616
|
Py_DECREF(ret);
|
|
1605
1617
|
return res;
|
|
1606
1618
|
}
|
|
@@ -2844,8 +2856,9 @@ bitarray_encode(bitarrayobject *self, PyObject *args)
|
|
|
2844
2856
|
|
|
2845
2857
|
/* extend self with the bitarrays from codedict */
|
|
2846
2858
|
while ((symbol = PyIter_Next(iter))) {
|
|
2847
|
-
|
|
2848
|
-
|
|
2859
|
+
if (PyDict_GetItemRef(codedict, symbol, &value) < 0)
|
|
2860
|
+
goto error;
|
|
2861
|
+
|
|
2849
2862
|
if (value == NULL) {
|
|
2850
2863
|
PyErr_Format(PyExc_ValueError,
|
|
2851
2864
|
"symbol not defined in prefix code: %A", symbol);
|
|
@@ -2854,6 +2867,9 @@ bitarray_encode(bitarrayobject *self, PyObject *args)
|
|
|
2854
2867
|
if (check_value(value) < 0 ||
|
|
2855
2868
|
extend_bitarray(self, (bitarrayobject *) value) < 0)
|
|
2856
2869
|
goto error;
|
|
2870
|
+
|
|
2871
|
+
Py_DECREF(symbol);
|
|
2872
|
+
Py_DECREF(value);
|
|
2857
2873
|
}
|
|
2858
2874
|
Py_DECREF(iter);
|
|
2859
2875
|
if (PyErr_Occurred()) /* from PyIter_Next() */
|
|
@@ -2862,6 +2878,8 @@ bitarray_encode(bitarrayobject *self, PyObject *args)
|
|
|
2862
2878
|
|
|
2863
2879
|
error:
|
|
2864
2880
|
Py_DECREF(iter);
|
|
2881
|
+
Py_DECREF(symbol);
|
|
2882
|
+
Py_XDECREF(value);
|
|
2865
2883
|
return NULL;
|
|
2866
2884
|
}
|
|
2867
2885
|
|
|
@@ -3023,8 +3041,10 @@ binode_to_dict(binode *nd, PyObject *dict, bitarrayobject *prefix)
|
|
|
3023
3041
|
|
|
3024
3042
|
if ((t = bitarray_cp(prefix)) == NULL)
|
|
3025
3043
|
return -1;
|
|
3026
|
-
if (resize(t, t->nbits + 1) < 0)
|
|
3044
|
+
if (resize(t, t->nbits + 1) < 0) {
|
|
3045
|
+
Py_DECREF(t);
|
|
3027
3046
|
return -1;
|
|
3047
|
+
}
|
|
3028
3048
|
setbit(t, t->nbits - 1, k);
|
|
3029
3049
|
ret = binode_to_dict(nd->child[k], dict, t);
|
|
3030
3050
|
Py_DECREF(t);
|
|
@@ -3321,12 +3341,12 @@ decodeiter_next(decodeiterobject *it)
|
|
|
3321
3341
|
static void
|
|
3322
3342
|
decodeiter_dealloc(decodeiterobject *it)
|
|
3323
3343
|
{
|
|
3344
|
+
PyObject_GC_UnTrack(it);
|
|
3324
3345
|
if (it->decodetree)
|
|
3325
3346
|
Py_DECREF(it->decodetree);
|
|
3326
3347
|
else /* when decodeiter was created from dict - free tree */
|
|
3327
3348
|
binode_delete(it->tree);
|
|
3328
3349
|
|
|
3329
|
-
PyObject_GC_UnTrack(it);
|
|
3330
3350
|
Py_DECREF(it->self);
|
|
3331
3351
|
PyObject_GC_Del(it);
|
|
3332
3352
|
}
|
|
@@ -3466,6 +3486,7 @@ static int
|
|
|
3466
3486
|
searchiter_traverse(searchiterobject *it, visitproc visit, void *arg)
|
|
3467
3487
|
{
|
|
3468
3488
|
Py_VISIT(it->self);
|
|
3489
|
+
Py_VISIT(it->sub);
|
|
3469
3490
|
return 0;
|
|
3470
3491
|
}
|
|
3471
3492
|
|
|
@@ -4044,7 +4065,8 @@ bits2bytes(PyObject *module, PyObject *n)
|
|
|
4044
4065
|
return PyErr_Format(PyExc_TypeError, "'int' object expected, "
|
|
4045
4066
|
"got '%s'", Py_TYPE(n)->tp_name);
|
|
4046
4067
|
|
|
4047
|
-
zero = PyLong_FromLong(0)
|
|
4068
|
+
if ((zero = PyLong_FromLong(0)) == NULL)
|
|
4069
|
+
return NULL;
|
|
4048
4070
|
cmp_res = PyObject_RichCompareBool(n, zero, Py_LT);
|
|
4049
4071
|
Py_DECREF(zero);
|
|
4050
4072
|
if (cmp_res < 0)
|
|
@@ -4054,13 +4076,17 @@ bits2bytes(PyObject *module, PyObject *n)
|
|
|
4054
4076
|
return NULL;
|
|
4055
4077
|
}
|
|
4056
4078
|
|
|
4057
|
-
seven = PyLong_FromLong(7)
|
|
4079
|
+
if ((seven = PyLong_FromLong(7)) == NULL)
|
|
4080
|
+
return NULL;
|
|
4058
4081
|
a = PyNumber_Add(n, seven); /* a = n + 7 */
|
|
4059
4082
|
Py_DECREF(seven);
|
|
4060
4083
|
if (a == NULL)
|
|
4061
4084
|
return NULL;
|
|
4062
4085
|
|
|
4063
|
-
eight = PyLong_FromLong(8)
|
|
4086
|
+
if ((eight = PyLong_FromLong(8)) == NULL) {
|
|
4087
|
+
Py_DECREF(a);
|
|
4088
|
+
return NULL;
|
|
4089
|
+
}
|
|
4064
4090
|
b = PyNumber_FloorDivide(a, eight); /* b = a // 8 */
|
|
4065
4091
|
Py_DECREF(eight);
|
|
4066
4092
|
Py_DECREF(a);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2019 -
|
|
2
|
+
Copyright (c) 2019 - 2026, Ilan Schnell; All Rights Reserved
|
|
3
3
|
bitarray is published under the PSF license.
|
|
4
4
|
|
|
5
5
|
This file contains the C implementation of some useful utility functions.
|
|
@@ -102,6 +102,9 @@ resize_lite(bitarrayobject *self, Py_ssize_t nbits)
|
|
|
102
102
|
|
|
103
103
|
self->ob_item = PyMem_Realloc(self->ob_item, newsize);
|
|
104
104
|
if (self->ob_item == NULL) {
|
|
105
|
+
Py_SET_SIZE(self, 0);
|
|
106
|
+
self->allocated = 0;
|
|
107
|
+
self->nbits = 0;
|
|
105
108
|
PyErr_NoMemory();
|
|
106
109
|
return -1;
|
|
107
110
|
}
|
|
@@ -1154,7 +1157,8 @@ byte_length(Py_ssize_t i)
|
|
|
1154
1157
|
BSI(1) = 32 (BSI = Buffer Size Indexable)
|
|
1155
1158
|
|
|
1156
1159
|
Moving from block type n to n + 1 multiplies the decoded block size
|
|
1157
|
-
by a factor of 256 (as
|
|
1160
|
+
by a factor of 256 (as one extra byte can index 256 times as much
|
|
1161
|
+
address space):
|
|
1158
1162
|
|
|
1159
1163
|
BSI(n + 1) = 256 * BSI(n)
|
|
1160
1164
|
*/
|
|
@@ -1281,7 +1285,8 @@ module_sc_rts(PyObject *module, PyObject *obj)
|
|
|
1281
1285
|
a.count(1, 8 * offset, 8 * offset + (1 << (8 * n)))
|
|
1282
1286
|
|
|
1283
1287
|
The offset must be divisible by SEGSIZE, as this functions makes use of
|
|
1284
|
-
running totals, stored in rts[].
|
|
1288
|
+
running totals, stored in rts[].
|
|
1289
|
+
Here, and in the following, 'offset' is in units of bytes. */
|
|
1285
1290
|
static Py_ssize_t
|
|
1286
1291
|
sc_count(bitarrayobject *a, Py_ssize_t *rts, Py_ssize_t offset, int n)
|
|
1287
1292
|
{
|
|
@@ -1968,8 +1973,10 @@ chdi_new(PyObject *module, PyObject *args)
|
|
|
1968
1973
|
return NULL;
|
|
1969
1974
|
|
|
1970
1975
|
it = PyObject_GC_New(chdi_obj, &CHDI_Type);
|
|
1971
|
-
if (it == NULL)
|
|
1972
|
-
|
|
1976
|
+
if (it == NULL) {
|
|
1977
|
+
Py_DECREF(symbol);
|
|
1978
|
+
return NULL;
|
|
1979
|
+
}
|
|
1973
1980
|
|
|
1974
1981
|
if ((count_sum = set_count(it->count, count)) < 0)
|
|
1975
1982
|
goto error;
|
|
@@ -1990,7 +1997,7 @@ chdi_new(PyObject *module, PyObject *args)
|
|
|
1990
1997
|
|
|
1991
1998
|
error:
|
|
1992
1999
|
it->array = NULL;
|
|
1993
|
-
|
|
2000
|
+
Py_DECREF(symbol);
|
|
1994
2001
|
it->symbol = NULL;
|
|
1995
2002
|
Py_DECREF(it);
|
|
1996
2003
|
return NULL;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (c) 2008 -
|
|
2
|
+
Copyright (c) 2008 - 2026, Ilan Schnell; All Rights Reserved
|
|
3
3
|
bitarray is published under the PSF license.
|
|
4
4
|
|
|
5
5
|
Author: Ilan Schnell
|
|
6
6
|
*/
|
|
7
|
-
#define BITARRAY_VERSION "3.8.
|
|
7
|
+
#define BITARRAY_VERSION "3.8.1"
|
|
8
8
|
|
|
9
9
|
#ifdef STDC_HEADERS
|
|
10
10
|
# include <stddef.h>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2008 -
|
|
1
|
+
# Copyright (c) 2008 - 2026, Ilan Schnell; All Rights Reserved
|
|
2
2
|
# bitarray is published under the PSF license.
|
|
3
3
|
#
|
|
4
4
|
# Author: Ilan Schnell
|
|
@@ -259,7 +259,7 @@ class CreateObjectTests(unittest.TestCase, Util):
|
|
|
259
259
|
self.assertEQUAL(a, bitarray(0, endian))
|
|
260
260
|
|
|
261
261
|
a = bitarray(buffer=b'A')
|
|
262
|
-
self.assertEqual(a.endian,
|
|
262
|
+
self.assertEqual(a.endian, get_default_endian())
|
|
263
263
|
self.assertEqual(len(a), 8)
|
|
264
264
|
|
|
265
265
|
def test_buffer_readonly(self):
|
|
@@ -2405,16 +2405,16 @@ class NumberTests(unittest.TestCase, Util):
|
|
|
2405
2405
|
@skipIf(is_pypy)
|
|
2406
2406
|
def test_imported(self):
|
|
2407
2407
|
a = bytearray([0xf0, 0x01, 0x02, 0x0f])
|
|
2408
|
-
b = bitarray(buffer=a)
|
|
2408
|
+
b = bitarray(buffer=a, endian='big')
|
|
2409
2409
|
self.assertFalse(b.readonly)
|
|
2410
2410
|
# operate on imported (writable) buffer
|
|
2411
2411
|
b[8:24] <<= 3
|
|
2412
2412
|
self.assertEqual(a, bytearray([0xf0, 0x08, 0x10, 0x0f]))
|
|
2413
|
-
b[0:9] |= bitarray("0000 1100 1")
|
|
2413
|
+
b[0:9] |= bitarray("0000 1100 1", 'big')
|
|
2414
2414
|
self.assertEqual(a, bytearray([0xfc, 0x88, 0x10, 0x0f]))
|
|
2415
|
-
b[23:] ^= bitarray("1 1110 1110")
|
|
2415
|
+
b[23:] ^= bitarray("1 1110 1110", 'big')
|
|
2416
2416
|
self.assertEqual(a, bytearray([0xfc, 0x88, 0x11, 0xe1]))
|
|
2417
|
-
b[16:] &= bitarray("1111 0000 1111 0000")
|
|
2417
|
+
b[16:] &= bitarray("1111 0000 1111 0000", 'big')
|
|
2418
2418
|
self.assertEqual(a, bytearray([0xfc, 0x88, 0x10, 0xe0]))
|
|
2419
2419
|
b >>= 8
|
|
2420
2420
|
self.assertEqual(a, bytearray([0x00, 0xfc, 0x88, 0x10]))
|
|
@@ -4038,7 +4038,7 @@ class FileTests(unittest.TestCase, Util):
|
|
|
4038
4038
|
with open(self.tmpfname, 'rb') as fi:
|
|
4039
4039
|
self.assertRaises(TypeError, a.fromfile, fi, None)
|
|
4040
4040
|
|
|
4041
|
-
def
|
|
4041
|
+
def test_fromfile_errors(self):
|
|
4042
4042
|
with open(self.tmpfname, 'wb') as fo:
|
|
4043
4043
|
fo.write(b'0123456789')
|
|
4044
4044
|
self.assertFileSize(10)
|
|
@@ -4052,6 +4052,13 @@ class FileTests(unittest.TestCase, Util):
|
|
|
4052
4052
|
self.assertRaisesMessage(TypeError, ".read() did not return "
|
|
4053
4053
|
"'bytes', got 'str'", a.fromfile, fi)
|
|
4054
4054
|
|
|
4055
|
+
def test_fromfile_exported_buffer(self):
|
|
4056
|
+
a = bitarray()
|
|
4057
|
+
v = memoryview(a) # export buffer — prevents resize/frombytes
|
|
4058
|
+
f = BytesIO(b'\x00' * 100)
|
|
4059
|
+
msg = "cannot resize bitarray that is exporting buffers"
|
|
4060
|
+
self.assertRaisesMessage(BufferError, msg, a.fromfile, f)
|
|
4061
|
+
|
|
4055
4062
|
def test_frombytes_invalid_reader(self):
|
|
4056
4063
|
class Reader:
|
|
4057
4064
|
def read(self, n):
|
|
@@ -4408,6 +4415,26 @@ class PrefixCodeTests(unittest.TestCase, Util):
|
|
|
4408
4415
|
msg = "symbol not defined in prefix code: None"
|
|
4409
4416
|
self.assertRaisesMessage(ValueError, msg, a.encode, d, [None, 2])
|
|
4410
4417
|
|
|
4418
|
+
def test_encode_symbol_ref_count(self):
|
|
4419
|
+
a = bitarray()
|
|
4420
|
+
codedict = {'a': bitarray('0')}
|
|
4421
|
+
# Generator yields a fresh object with refcount 1
|
|
4422
|
+
def gen():
|
|
4423
|
+
yield type('X', (), {
|
|
4424
|
+
'__hash__': lambda s: 42,
|
|
4425
|
+
'__repr__': lambda s: 'X()'
|
|
4426
|
+
})()
|
|
4427
|
+
self.assertRaises(ValueError, a.encode, codedict, gen())
|
|
4428
|
+
|
|
4429
|
+
def test_encode_swallowed_exception(self):
|
|
4430
|
+
a = bitarray()
|
|
4431
|
+
codedict = {'a': bitarray('0')}
|
|
4432
|
+
class Unhashable:
|
|
4433
|
+
def __hash__(self):
|
|
4434
|
+
raise MemoryError("OOM in __hash__")
|
|
4435
|
+
# MemoryError is not swallowed by ValueError
|
|
4436
|
+
self.assertRaises(MemoryError, a.encode, codedict, [Unhashable()])
|
|
4437
|
+
|
|
4411
4438
|
def test_encode_not_iterable(self):
|
|
4412
4439
|
d = {'a': bitarray('0'), 'b': bitarray('1')}
|
|
4413
4440
|
a = bitarray()
|
|
@@ -4714,10 +4741,10 @@ class BufferImportTests(unittest.TestCase, Util):
|
|
|
4714
4741
|
@skipIf(is_pypy)
|
|
4715
4742
|
def test_bitarray_shared_sections(self):
|
|
4716
4743
|
a = urandom_2(0x2000, 'big')
|
|
4717
|
-
b = bitarray(buffer=memoryview(a)[0x100:0x300])
|
|
4744
|
+
b = bitarray(buffer=memoryview(a)[0x100:0x300], endian='big')
|
|
4718
4745
|
self.assertEqual(b.buffer_info().address,
|
|
4719
4746
|
a.buffer_info().address + 0x100)
|
|
4720
|
-
c = bitarray(buffer=memoryview(a)[0x200:0x800])
|
|
4747
|
+
c = bitarray(buffer=memoryview(a)[0x200:0x800], endian='big')
|
|
4721
4748
|
self.assertEqual(c.buffer_info().address,
|
|
4722
4749
|
a.buffer_info().address + 0x200)
|
|
4723
4750
|
self.assertEqual(a[8 * 0x100 : 8 * 0x300], b)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2019 -
|
|
1
|
+
# Copyright (c) 2019 - 2026, Ilan Schnell; All Rights Reserved
|
|
2
2
|
# bitarray is published under the PSF license.
|
|
3
3
|
#
|
|
4
4
|
# Author: Ilan Schnell
|
|
@@ -1400,7 +1400,9 @@ class HexlifyTests(unittest.TestCase, Util):
|
|
|
1400
1400
|
|
|
1401
1401
|
def test_hex2ba_whitespace(self):
|
|
1402
1402
|
self.assertEqual(hex2ba("F1 FA %s f3 c0" % whitespace),
|
|
1403
|
-
bitarray("11110001 11111010 11110011 11000000"
|
|
1403
|
+
bitarray("11110001 11111010 11110011 11000000"
|
|
1404
|
+
if get_default_endian() == "big" else
|
|
1405
|
+
"11111000 11110101 11111100 00110000"))
|
|
1404
1406
|
self.assertEQUAL(hex2ba(b' a F ', 'big'),
|
|
1405
1407
|
bitarray('1010 1111', 'big'))
|
|
1406
1408
|
self.assertEQUAL(hex2ba(860 * " " + '0 1D' + 590 * " ", 'little'),
|
|
@@ -2251,7 +2253,8 @@ class IntegerizationTests(unittest.TestCase, Util):
|
|
|
2251
2253
|
(3691038, '1110000101001000011110')]:
|
|
2252
2254
|
ab = bitarray(sa, 'big')
|
|
2253
2255
|
al = bitarray(sa[::-1], 'little')
|
|
2254
|
-
self.assertEQUAL(int2ba(i),
|
|
2256
|
+
self.assertEQUAL(int2ba(i),
|
|
2257
|
+
ab if get_default_endian() == 'big' else al)
|
|
2255
2258
|
self.assertEQUAL(int2ba(i, endian='big'), ab)
|
|
2256
2259
|
self.assertEQUAL(int2ba(i, endian='little'), al)
|
|
2257
2260
|
self.assertEqual(ba2int(ab), ba2int(al), i)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bitarray
|
|
3
|
-
Version: 3.8.
|
|
3
|
+
Version: 3.8.1
|
|
4
4
|
Summary: efficient arrays of booleans -- C extension
|
|
5
5
|
Home-page: https://github.com/ilanschnell/bitarray
|
|
6
6
|
Author: Ilan Schnell
|
|
@@ -91,7 +91,7 @@ Once you have installed the package, you may want to test it:
|
|
|
91
91
|
|
|
92
92
|
$ python -c 'import bitarray; bitarray.test()'
|
|
93
93
|
bitarray is installed in: /Users/ilan/bitarray/bitarray
|
|
94
|
-
bitarray version: 3.8.
|
|
94
|
+
bitarray version: 3.8.1
|
|
95
95
|
sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
|
|
96
96
|
sys.prefix: /Users/ilan/miniforge
|
|
97
97
|
pointer size: 64 bit
|
|
@@ -107,7 +107,7 @@ Once you have installed the package, you may want to test it:
|
|
|
107
107
|
.........................................................................
|
|
108
108
|
................................................................
|
|
109
109
|
----------------------------------------------------------------------
|
|
110
|
-
Ran
|
|
110
|
+
Ran 598 tests in 0.165s
|
|
111
111
|
|
|
112
112
|
OK
|
|
113
113
|
|
|
@@ -354,7 +354,7 @@ and can therefore be used as a dictionary key:
|
|
|
354
354
|
Reference
|
|
355
355
|
=========
|
|
356
356
|
|
|
357
|
-
bitarray version: 3.8.
|
|
357
|
+
bitarray version: 3.8.1 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
|
|
358
358
|
|
|
359
359
|
In the following, ``item`` and ``value`` are usually a single bit -
|
|
360
360
|
an integer 0 or 1.
|
|
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
|