Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bools mis-classified as ints when using tx_obj #91

Open
robberwick opened this issue Apr 5, 2024 · 0 comments
Open

bools mis-classified as ints when using tx_obj #91

robberwick opened this issue Apr 5, 2024 · 0 comments

Comments

@robberwick
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant