bitarray 3.8.0__tar.gz → 3.8.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.
@@ -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 - 2025 Ilan Schnell; All Rights Reserved" are retained in bitarray
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.0
3
+ Version: 3.8.2
4
4
  Summary: efficient arrays of booleans -- C extension
5
5
  Home-page: https://github.com/ilanschnell/bitarray
6
6
  Author: Ilan Schnell
@@ -11,7 +11,6 @@ Classifier: Intended Audience :: Developers
11
11
  Classifier: Operating System :: OS Independent
12
12
  Classifier: Programming Language :: C
13
13
  Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.6
15
14
  Classifier: Programming Language :: Python :: 3.7
16
15
  Classifier: Programming Language :: Python :: 3.8
17
16
  Classifier: Programming Language :: Python :: 3.9
@@ -91,7 +90,7 @@ Once you have installed the package, you may want to test it:
91
90
 
92
91
  $ python -c 'import bitarray; bitarray.test()'
93
92
  bitarray is installed in: /Users/ilan/bitarray/bitarray
94
- bitarray version: 3.8.0
93
+ bitarray version: 3.8.2
95
94
  sys.version: 3.13.5 (main, Jun 16 2025) [Clang 18.1.8]
96
95
  sys.prefix: /Users/ilan/miniforge
97
96
  pointer size: 64 bit
@@ -107,7 +106,7 @@ Once you have installed the package, you may want to test it:
107
106
  .........................................................................
108
107
  ................................................................
109
108
  ----------------------------------------------------------------------
110
- Ran 595 tests in 0.165s
109
+ Ran 598 tests in 0.165s
111
110
 
112
111
  OK
113
112
 
@@ -354,7 +353,7 @@ and can therefore be used as a dictionary key:
354
353
  Reference
355
354
  =========
356
355
 
357
- bitarray version: 3.8.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
356
+ bitarray version: 3.8.2 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
358
357
 
359
358
  In the following, ``item`` and ``value`` are usually a single bit -
360
359
  an integer 0 or 1.
@@ -378,7 +377,7 @@ The bitarray object:
378
377
 
379
378
  ``endian``: Specifies the bit-endianness of the created bitarray object.
380
379
  Allowed values are ``big`` and ``little`` (the default is ``big``).
381
- The bit-endianness effects the buffer representation of the bitarray.
380
+ The bit-endianness affects the buffer representation of the bitarray.
382
381
 
383
382
  ``buffer``: Any object which exposes a buffer. When provided, ``initializer``
384
383
  cannot be present (or has to be ``None``). The imported buffer may be
@@ -473,7 +472,7 @@ bitarray methods:
473
472
 
474
473
 
475
474
  ``extend(iterable, /)``
476
- Append items from to the end of the bitarray.
475
+ Append items from iterable to the end of the bitarray.
477
476
  If ``iterable`` is a (Unicode) string, each ``0`` and ``1`` are appended as
478
477
  bits (ignoring whitespace and underscore).
479
478
 
@@ -504,7 +503,7 @@ bitarray methods:
504
503
 
505
504
  ``fromfile(f, n=-1, /)``
506
505
  Extend bitarray with up to ``n`` bytes read from file object ``f`` (or any
507
- other binary stream what supports a ``.read()`` method, e.g. ``io.BytesIO``).
506
+ other binary stream that supports a ``.read()`` method, e.g. ``io.BytesIO``).
508
507
  Each read byte will add eight bits to the bitarray. When ``n`` is omitted
509
508
  or negative, reads and extends all data until EOF.
510
509
  When ``n`` is non-negative but exceeds the available data, ``EOFError`` is
@@ -524,8 +523,9 @@ bitarray methods:
524
523
 
525
524
 
526
525
  ``invert(index=<all bits>, /)``
527
- Invert all bits in bitarray (in-place).
528
- When the optional ``index`` is given, only invert the single bit at ``index``.
526
+ Invert bits in-place. When ``index`` is omitted, invert all bits.
527
+ When ``index`` is an integer, invert the single bit at index.
528
+ When ``index`` is a slice, invert the selected bits.
529
529
 
530
530
  New in version 1.5.3: optional index argument
531
531
 
@@ -608,7 +608,7 @@ bitarray methods:
608
608
 
609
609
  ``unpack(zero=b'\x00', one=b'\x01')`` -> bytes
610
610
  Return bytes that contain one byte for each bit in the bitarray,
611
- using specified mapping.
611
+ using the specified mapping.
612
612
 
613
613
 
614
614
  bitarray data descriptors:
@@ -683,7 +683,8 @@ This sub-module was added in version 1.2.
683
683
  ``ba2base(n, bitarray, /, group=0, sep=' ')`` -> str
684
684
  Return a string containing the base ``n`` ASCII representation of
685
685
  the bitarray. Allowed values for ``n`` are 2, 4, 8, 16, 32 and 64.
686
- The bitarray has to be multiple of length 1, 2, 3, 4, 5 or 6 respectively.
686
+ The bitarray has to have a length divisible by 1, 2, 3, 4, 5 or 6
687
+ respectively.
687
688
  For ``n=32`` the RFC 4648 Base32 alphabet is used, and for ``n=64`` the
688
689
  standard base 64 alphabet is used.
689
690
  When grouped, the string ``sep`` is inserted between groups
@@ -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.0
60
+ bitarray version: 3.8.2
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 595 tests in 0.165s
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.0 -- `change log <https://github.com/ilanschnell/bitarray/blob/master/doc/changelog.rst>`__
323
+ bitarray version: 3.8.2 -- `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.
@@ -344,7 +344,7 @@ The bitarray object:
344
344
 
345
345
  ``endian``: Specifies the bit-endianness of the created bitarray object.
346
346
  Allowed values are ``big`` and ``little`` (the default is ``big``).
347
- The bit-endianness effects the buffer representation of the bitarray.
347
+ The bit-endianness affects the buffer representation of the bitarray.
348
348
 
349
349
  ``buffer``: Any object which exposes a buffer. When provided, ``initializer``
350
350
  cannot be present (or has to be ``None``). The imported buffer may be
@@ -439,7 +439,7 @@ bitarray methods:
439
439
 
440
440
 
441
441
  ``extend(iterable, /)``
442
- Append items from to the end of the bitarray.
442
+ Append items from iterable to the end of the bitarray.
443
443
  If ``iterable`` is a (Unicode) string, each ``0`` and ``1`` are appended as
444
444
  bits (ignoring whitespace and underscore).
445
445
 
@@ -470,7 +470,7 @@ bitarray methods:
470
470
 
471
471
  ``fromfile(f, n=-1, /)``
472
472
  Extend bitarray with up to ``n`` bytes read from file object ``f`` (or any
473
- other binary stream what supports a ``.read()`` method, e.g. ``io.BytesIO``).
473
+ other binary stream that supports a ``.read()`` method, e.g. ``io.BytesIO``).
474
474
  Each read byte will add eight bits to the bitarray. When ``n`` is omitted
475
475
  or negative, reads and extends all data until EOF.
476
476
  When ``n`` is non-negative but exceeds the available data, ``EOFError`` is
@@ -490,8 +490,9 @@ bitarray methods:
490
490
 
491
491
 
492
492
  ``invert(index=<all bits>, /)``
493
- Invert all bits in bitarray (in-place).
494
- When the optional ``index`` is given, only invert the single bit at ``index``.
493
+ Invert bits in-place. When ``index`` is omitted, invert all bits.
494
+ When ``index`` is an integer, invert the single bit at index.
495
+ When ``index`` is a slice, invert the selected bits.
495
496
 
496
497
  New in version 1.5.3: optional index argument
497
498
 
@@ -574,7 +575,7 @@ bitarray methods:
574
575
 
575
576
  ``unpack(zero=b'\x00', one=b'\x01')`` -> bytes
576
577
  Return bytes that contain one byte for each bit in the bitarray,
577
- using specified mapping.
578
+ using the specified mapping.
578
579
 
579
580
 
580
581
  bitarray data descriptors:
@@ -649,7 +650,8 @@ This sub-module was added in version 1.2.
649
650
  ``ba2base(n, bitarray, /, group=0, sep=' ')`` -> str
650
651
  Return a string containing the base ``n`` ASCII representation of
651
652
  the bitarray. Allowed values for ``n`` are 2, 4, 8, 16, 32 and 64.
652
- The bitarray has to be multiple of length 1, 2, 3, 4, 5 or 6 respectively.
653
+ The bitarray has to have a length divisible by 1, 2, 3, 4, 5 or 6
654
+ respectively.
653
655
  For ``n=32`` the RFC 4648 Base32 alphabet is used, and for ``n=64`` the
654
656
  standard base 64 alphabet is used.
655
657
  When grouped, the string ``sep`` is inserted between groups
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2008 - 2025, Ilan Schnell; All Rights Reserved
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,4 +1,4 @@
1
- # Copyright (c) 2021 - 2025, Ilan Schnell; All Rights Reserved
1
+ # Copyright (c) 2021 - 2026, Ilan Schnell; All Rights Reserved
2
2
  #
3
3
  # This stub, as well as util.pyi, are tested with Python 3.10 and mypy 1.11.2
4
4
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (c) 2008 - 2025, Ilan Schnell; All Rights Reserved
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.
@@ -24,6 +24,34 @@ static PyTypeObject Bitarray_Type;
24
24
  #define bitarray_Check(obj) PyObject_TypeCheck((obj), &Bitarray_Type)
25
25
 
26
26
 
27
+ static size_t
28
+ new_allocation(size_t size, size_t allocated, size_t newsize)
29
+ {
30
+ assert(allocated >= size);
31
+ assert(newsize > 0);
32
+
33
+ if (allocated >= newsize) {
34
+ /* current buffer is large enough to host the requested size */
35
+ if (newsize >= allocated / 2)
36
+ return allocated; /* minor downsize - keep current allocation */
37
+
38
+ return newsize; /* major downsize - shrink to exact size */
39
+ }
40
+ else {
41
+ /* need to grow buffer */
42
+ size_t new_alloc = newsize;
43
+ /* overallocate when previous size isn't zero and when growth
44
+ is moderate */
45
+ if (size != 0 && newsize / 2 <= allocated) {
46
+ /* overallocate proportional to the bitarray size and
47
+ add padding to make the allocated size multiple of 4 */
48
+ new_alloc += (newsize >> 4) + (newsize < 8 ? 3 : 7);
49
+ new_alloc &= ~(size_t) 3;
50
+ }
51
+ return new_alloc;
52
+ }
53
+ }
54
+
27
55
  static int
28
56
  resize(bitarrayobject *self, Py_ssize_t nbits)
29
57
  {
@@ -69,33 +97,21 @@ resize(bitarrayobject *self, Py_ssize_t nbits)
69
97
  return 0;
70
98
  }
71
99
 
72
- if (allocated >= newsize) {
73
- /* current buffer is large enough to host the requested size */
74
- if (newsize >= allocated / 2) {
75
- /* minor downsize, bypass reallocation */
76
- Py_SET_SIZE(self, newsize);
77
- self->nbits = nbits;
78
- return 0;
79
- }
80
- /* major downsize, resize down to exact size */
81
- new_allocated = newsize;
82
- }
83
- else {
84
- /* need to grow buffer */
85
- new_allocated = newsize;
86
- /* overallocate when previous size isn't zero and when growth
87
- is moderate */
88
- if (size != 0 && newsize / 2 <= allocated) {
89
- /* overallocate proportional to the bitarray size and
90
- add padding to make the allocated size multiple of 4 */
91
- new_allocated += (newsize >> 4) + (newsize < 8 ? 3 : 7);
92
- new_allocated &= ~(size_t) 3;
93
- }
100
+ new_allocated = new_allocation(size, allocated, newsize);
101
+
102
+ if (new_allocated == allocated) {
103
+ /* bypass reallocation */
104
+ Py_SET_SIZE(self, newsize);
105
+ self->nbits = nbits;
106
+ return 0;
94
107
  }
95
108
 
96
109
  assert(new_allocated >= newsize);
97
110
  self->ob_item = PyMem_Realloc(self->ob_item, new_allocated);
98
111
  if (self->ob_item == NULL) {
112
+ Py_SET_SIZE(self, 0);
113
+ self->allocated = 0;
114
+ self->nbits = 0;
99
115
  PyErr_NoMemory();
100
116
  return -1;
101
117
  }
@@ -200,7 +216,7 @@ bytereverse(char *p, Py_ssize_t n)
200
216
  /* The following two functions operate on first n bytes in buffer.
201
217
  Within this region, they shift all bits by k positions to right,
202
218
  i.e. towards higher addresses.
203
- They operate on little-endian and bit-endian bitarrays respectively.
219
+ They operate on little-endian and big-endian bitarrays respectively.
204
220
  As we shift right, we need to start with the highest address and loop
205
221
  downwards such that lower bytes are still unaltered.
206
222
  See also devel/shift_r8.c
@@ -1028,7 +1044,7 @@ bitarray_buffer_info(bitarrayobject *self)
1028
1044
  readonly = PyBool_FromLong(self->readonly);
1029
1045
  imported = PyBool_FromLong(self->buffer ? 1 : 0);
1030
1046
  if (address == NULL || readonly == NULL || imported == NULL)
1031
- return NULL;
1047
+ goto error;
1032
1048
 
1033
1049
  args = Py_BuildValue("OnsnnOOi",
1034
1050
  address,
@@ -1039,12 +1055,21 @@ bitarray_buffer_info(bitarrayobject *self)
1039
1055
  readonly,
1040
1056
  imported,
1041
1057
  self->ob_exports);
1058
+ if (args == NULL)
1059
+ goto error;
1060
+
1042
1061
  Py_DECREF(address);
1043
1062
  Py_DECREF(readonly);
1044
1063
  Py_DECREF(imported);
1045
1064
  res = PyObject_CallObject(info, args);
1046
1065
  Py_DECREF(args);
1047
1066
  return res;
1067
+
1068
+ error:
1069
+ Py_XDECREF(address);
1070
+ Py_XDECREF(readonly);
1071
+ Py_XDECREF(imported);
1072
+ return NULL;
1048
1073
  }
1049
1074
 
1050
1075
  PyDoc_STRVAR(buffer_info_doc,
@@ -1182,7 +1207,7 @@ bitarray_extend(bitarrayobject *self, PyObject *obj)
1182
1207
  PyDoc_STRVAR(extend_doc,
1183
1208
  "extend(iterable, /)\n\
1184
1209
  \n\
1185
- Append items from to the end of the bitarray.\n\
1210
+ Append items from iterable to the end of the bitarray.\n\
1186
1211
  If `iterable` is a (Unicode) string, each `0` and `1` are appended as\n\
1187
1212
  bits (ignoring whitespace and underscore).");
1188
1213
 
@@ -1334,7 +1359,8 @@ bitarray_invert(bitarrayobject *self, PyObject *args)
1334
1359
  invert_span(self, 0, self->nbits);
1335
1360
  }
1336
1361
  else {
1337
- return PyErr_Format(PyExc_TypeError, "index expect, not '%s' object",
1362
+ return PyErr_Format(PyExc_TypeError,
1363
+ "index expected, not '%s' object",
1338
1364
  Py_TYPE(arg)->tp_name);
1339
1365
  }
1340
1366
  Py_RETURN_NONE;
@@ -1343,8 +1369,9 @@ bitarray_invert(bitarrayobject *self, PyObject *args)
1343
1369
  PyDoc_STRVAR(invert_doc,
1344
1370
  "invert(index=<all bits>, /)\n\
1345
1371
  \n\
1346
- Invert all bits in bitarray (in-place).\n\
1347
- When the optional `index` is given, only invert the single bit at `index`.");
1372
+ Invert bits in-place. When `index` is omitted, invert all bits.\n\
1373
+ When `index` is an integer, invert the single bit at index.\n\
1374
+ When `index` is a slice, invert the selected bits.");
1348
1375
 
1349
1376
 
1350
1377
  static PyObject *
@@ -1545,7 +1572,7 @@ bitarray_frombytes(bitarrayobject *self, PyObject *buffer)
1545
1572
  assert(Py_SIZE(self) == n + view.len);
1546
1573
  memcpy(self->ob_item + n, (char *) view.buf, (size_t) view.len);
1547
1574
 
1548
- /* remove pad bits staring at previous bit length (8 * n - p) */
1575
+ /* remove pad bits starting at previous bit length (8 * n - p) */
1549
1576
  if (delete_n(self, 8 * n - p, p) < 0)
1550
1577
  goto error;
1551
1578
 
@@ -1600,7 +1627,7 @@ extend_fread(bitarrayobject *self, PyObject *f, Py_ssize_t n)
1600
1627
  ret = bitarray_frombytes(self, bytes);
1601
1628
  Py_DECREF(bytes);
1602
1629
  if (ret == NULL)
1603
- res = -1;
1630
+ return -1;
1604
1631
  Py_DECREF(ret);
1605
1632
  return res;
1606
1633
  }
@@ -1642,7 +1669,7 @@ PyDoc_STRVAR(fromfile_doc,
1642
1669
  "fromfile(f, n=-1, /)\n\
1643
1670
  \n\
1644
1671
  Extend bitarray with up to `n` bytes read from file object `f` (or any\n\
1645
- other binary stream what supports a `.read()` method, e.g. `io.BytesIO`).\n\
1672
+ other binary stream that supports a `.read()` method, e.g. `io.BytesIO`).\n\
1646
1673
  Each read byte will add eight bits to the bitarray. When `n` is omitted\n\
1647
1674
  or negative, reads and extends all data until EOF.\n\
1648
1675
  When `n` is non-negative but exceeds the available data, `EOFError` is\n\
@@ -1661,7 +1688,7 @@ bitarray_tofile(bitarrayobject *self, PyObject *f)
1661
1688
  Py_ssize_t size = Py_MIN(nbytes - offset, BLOCKSIZE);
1662
1689
 
1663
1690
  assert(size >= 0 && offset + size <= nbytes);
1664
- /* basically: f.write(memoryview(self)[offset:offset + size] */
1691
+ /* basically: f.write(memoryview(self)[offset:offset + size]) */
1665
1692
  ret = PyObject_CallMethod(f, "write", "y#",
1666
1693
  self->ob_item + offset, size);
1667
1694
  if (ret == NULL)
@@ -1751,7 +1778,7 @@ PyDoc_STRVAR(unpack_doc,
1751
1778
  "unpack(zero=b'\\x00', one=b'\\x01') -> bytes\n\
1752
1779
  \n\
1753
1780
  Return bytes that contain one byte for each bit in the bitarray,\n\
1754
- using specified mapping.");
1781
+ using the specified mapping.");
1755
1782
 
1756
1783
 
1757
1784
  static PyObject *
@@ -2844,8 +2871,9 @@ bitarray_encode(bitarrayobject *self, PyObject *args)
2844
2871
 
2845
2872
  /* extend self with the bitarrays from codedict */
2846
2873
  while ((symbol = PyIter_Next(iter))) {
2847
- value = PyDict_GetItem(codedict, symbol);
2848
- Py_DECREF(symbol);
2874
+ if (PyDict_GetItemRef(codedict, symbol, &value) < 0)
2875
+ goto error;
2876
+
2849
2877
  if (value == NULL) {
2850
2878
  PyErr_Format(PyExc_ValueError,
2851
2879
  "symbol not defined in prefix code: %A", symbol);
@@ -2854,6 +2882,9 @@ bitarray_encode(bitarrayobject *self, PyObject *args)
2854
2882
  if (check_value(value) < 0 ||
2855
2883
  extend_bitarray(self, (bitarrayobject *) value) < 0)
2856
2884
  goto error;
2885
+
2886
+ Py_DECREF(symbol);
2887
+ Py_DECREF(value);
2857
2888
  }
2858
2889
  Py_DECREF(iter);
2859
2890
  if (PyErr_Occurred()) /* from PyIter_Next() */
@@ -2862,6 +2893,8 @@ bitarray_encode(bitarrayobject *self, PyObject *args)
2862
2893
 
2863
2894
  error:
2864
2895
  Py_DECREF(iter);
2896
+ Py_DECREF(symbol);
2897
+ Py_XDECREF(value);
2865
2898
  return NULL;
2866
2899
  }
2867
2900
 
@@ -3023,8 +3056,10 @@ binode_to_dict(binode *nd, PyObject *dict, bitarrayobject *prefix)
3023
3056
 
3024
3057
  if ((t = bitarray_cp(prefix)) == NULL)
3025
3058
  return -1;
3026
- if (resize(t, t->nbits + 1) < 0)
3059
+ if (resize(t, t->nbits + 1) < 0) {
3060
+ Py_DECREF(t);
3027
3061
  return -1;
3062
+ }
3028
3063
  setbit(t, t->nbits - 1, k);
3029
3064
  ret = binode_to_dict(nd->child[k], dict, t);
3030
3065
  Py_DECREF(t);
@@ -3147,7 +3182,7 @@ PyDoc_STRVAR(complete_doc,
3147
3182
  "complete() -> bool\n\
3148
3183
  \n\
3149
3184
  Return whether tree is complete. That is, whether or not all\n\
3150
- nodes have both children (unless they are symbols nodes).");
3185
+ nodes have both children (unless they are symbol nodes).");
3151
3186
 
3152
3187
 
3153
3188
  static PyObject *
@@ -3312,7 +3347,7 @@ decodeiter_next(decodeiterobject *it)
3312
3347
  PyObject *symbol;
3313
3348
 
3314
3349
  symbol = binode_traverse(it->tree, it->self, &(it->index));
3315
- if (symbol == NULL) /* stop iteration OR error occured */
3350
+ if (symbol == NULL) /* stop iteration OR error occurred */
3316
3351
  return NULL;
3317
3352
  Py_INCREF(symbol);
3318
3353
  return symbol;
@@ -3321,12 +3356,12 @@ decodeiter_next(decodeiterobject *it)
3321
3356
  static void
3322
3357
  decodeiter_dealloc(decodeiterobject *it)
3323
3358
  {
3359
+ PyObject_GC_UnTrack(it);
3324
3360
  if (it->decodetree)
3325
3361
  Py_DECREF(it->decodetree);
3326
3362
  else /* when decodeiter was created from dict - free tree */
3327
3363
  binode_delete(it->tree);
3328
3364
 
3329
- PyObject_GC_UnTrack(it);
3330
3365
  Py_DECREF(it->self);
3331
3366
  PyObject_GC_Del(it);
3332
3367
  }
@@ -3466,6 +3501,7 @@ static int
3466
3501
  searchiter_traverse(searchiterobject *it, visitproc visit, void *arg)
3467
3502
  {
3468
3503
  Py_VISIT(it->self);
3504
+ Py_VISIT(it->sub);
3469
3505
  return 0;
3470
3506
  }
3471
3507
 
@@ -3702,9 +3738,9 @@ newbitarray_from_bytes(PyTypeObject *type, PyObject *buffer, int endian)
3702
3738
  }
3703
3739
 
3704
3740
  /* As of bitarray version 2.9.0, "bitarray(nbits)" will initialize all items
3705
- to 0 (previously, the buffer was be uninitialized).
3741
+ to 0 (previously, the buffer was uninitialized).
3706
3742
  However, for speed, one might want to create an uninitialized bitarray.
3707
- In 2.9.1, we added the ability to created uninitialized bitarrays again,
3743
+ In 2.9.1, we added the ability to create uninitialized bitarrays again,
3708
3744
  using "bitarray(nbits, endian, Ellipsis)".
3709
3745
  */
3710
3746
  static PyObject *
@@ -3982,7 +4018,7 @@ Optional keyword arguments:\n\
3982
4018
  \n\
3983
4019
  `endian`: Specifies the bit-endianness of the created bitarray object.\n\
3984
4020
  Allowed values are `big` and `little` (the default is `big`).\n\
3985
- The bit-endianness effects the buffer representation of the bitarray.\n\
4021
+ The bit-endianness affects the buffer representation of the bitarray.\n\
3986
4022
  \n\
3987
4023
  `buffer`: Any object which exposes a buffer. When provided, `initializer`\n\
3988
4024
  cannot be present (or has to be `None`). The imported buffer may be\n\
@@ -4044,7 +4080,8 @@ bits2bytes(PyObject *module, PyObject *n)
4044
4080
  return PyErr_Format(PyExc_TypeError, "'int' object expected, "
4045
4081
  "got '%s'", Py_TYPE(n)->tp_name);
4046
4082
 
4047
- zero = PyLong_FromLong(0);
4083
+ if ((zero = PyLong_FromLong(0)) == NULL)
4084
+ return NULL;
4048
4085
  cmp_res = PyObject_RichCompareBool(n, zero, Py_LT);
4049
4086
  Py_DECREF(zero);
4050
4087
  if (cmp_res < 0)
@@ -4054,13 +4091,17 @@ bits2bytes(PyObject *module, PyObject *n)
4054
4091
  return NULL;
4055
4092
  }
4056
4093
 
4057
- seven = PyLong_FromLong(7);
4094
+ if ((seven = PyLong_FromLong(7)) == NULL)
4095
+ return NULL;
4058
4096
  a = PyNumber_Add(n, seven); /* a = n + 7 */
4059
4097
  Py_DECREF(seven);
4060
4098
  if (a == NULL)
4061
4099
  return NULL;
4062
4100
 
4063
- eight = PyLong_FromLong(8);
4101
+ if ((eight = PyLong_FromLong(8)) == NULL) {
4102
+ Py_DECREF(a);
4103
+ return NULL;
4104
+ }
4064
4105
  b = PyNumber_FloorDivide(a, eight); /* b = a // 8 */
4065
4106
  Py_DECREF(eight);
4066
4107
  Py_DECREF(a);
@@ -4177,7 +4218,7 @@ sysinfo(PyObject *module, PyObject *args)
4177
4218
  PyDoc_STRVAR(sysinfo_doc,
4178
4219
  "_sysinfo(key) -> int\n\
4179
4220
  \n\
4180
- Return system and compile specific information given a key.");
4221
+ Return system- and compile-specific information given a key.");
4181
4222
 
4182
4223
 
4183
4224
  static PyMethodDef module_functions[] = {