ethereum/py_ecc

Cleanup isinstance checks for integers to disallow booleans

開放

#30 建立於 2018年12月4日

 (0 則留言) (0 個反應) (0 位負責人)Python (88 個分叉)auto 404
Good First Issue

倉庫指標

星標
 (231 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

What is wrong?

Lots of places in the codebase do assertions like isinstance(v, int) to check that something is an integer. Since python considers True and False to be integer types these checks won't disallow passing in a bool value.

How can it be fixed

Probably need to add a single utility and make use of it everywhere that we do these checks.

def assert_strictly_integer(v):
    assert isinstance(v, int) and not isinstance(v, bool)

貢獻者指南