ethereum/py_ecc

Cleanup isinstance checks for integers to disallow booleans

Offen

#30 geöffnet am 04.12.2018

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (88 Forks)auto 404
Good First Issue

Repository-Metriken

Stars
 (231 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

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)

Contributor Guide