Skip to content

bools mis-classified as ints when using tx_obj #91

Open
@robberwick

Description

@robberwick

While writing tests for tx_obj, I noticed that attempting to call tx_obj(True) resulted in incorrect values being inserted in tx_buff

The culprit is the ordering of the instance type tests. For historic reasons, bool is a subclass of int, so True is an instance of int. (Originally, Python had no bool type, and things that returned truth values returned 1 or 0). Thus, as isinstance(val, int) is performed before isinstance(val, bool), the True is misidentified as an int. Swapping the order of operations fixes this problem.

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