Skip to content

Non-frozen bitarrays appear hashable on Windows installs #232

Description

@andrew-vant

I'm not sure what to make of this, but it tripped me up when isinstance(Hashable) unexpectedly returned true for bitarray objects. Example:

Python 3.12.9 (tags/v3.12.9:fdb8142, Feb  4 2025, 15:27:58) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bitarray import bitarray
>>> from collections.abc import Hashable
>>> ba = bitarray()
>>> isinstance(ba, Hashable)
True
>>> ba.__hash__
<method-wrapper '__hash__' of bitarray.bitarray object at 0x000001F1A18633C0>
>>> ba.__hash__()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'bitarray.bitarray'

The weird part is that it only happens on windows. The isinstance check correctly returns false on linux, and the __hash__ method doesn't exist.

Tested on python 3.12, bitarray 2.9.2 and 3.3.0. [edit: installed on windows via py -m pip install bitarray=={version}, on linux installed from apt)]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions