Skip to content

Commit

Permalink
change behaviour of same_type function in RestrictedPython.Utilities …
Browse files Browse the repository at this point in the history
…so that it returns a bool instaed of 0 or 1.

This is a proposal for #122
  • Loading branch information
loechel committed Oct 2, 2018
1 parent 42b4be0 commit dafdc26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/RestrictedPython/Utilities.py
Expand Up @@ -37,8 +37,8 @@ def same_type(arg1, *args):
t = getattr(arg1, '__class__', type(arg1))
for arg in args:
if getattr(arg, '__class__', type(arg)) is not t:
return 0
return 1
return False
return True


utility_builtins['same_type'] = same_type
Expand Down
4 changes: 2 additions & 2 deletions tests/builtins/test_utilities.py
Expand Up @@ -76,7 +76,7 @@ def test_sametype_only_two_args_different():

class Foo(object):
pass
assert same_type(object(), Foo()) is 0
assert same_type(object(), Foo()) is False


def test_sametype_only_multiple_args_same():
Expand All @@ -89,7 +89,7 @@ def test_sametype_only_multipe_args_one_different():

class Foo(object):
pass
assert same_type(object(), object(), Foo()) is 0
assert same_type(object(), object(), Foo()) is False


def test_test_single_value_true():
Expand Down

0 comments on commit dafdc26

Please sign in to comment.