Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix deprecations for py3k
  • Loading branch information
Ryan P Kilby committed Sep 16, 2016
commit 3bdb0e9dd8b8f098111fad4a874ee99d392e944a
12 changes: 12 additions & 0 deletions rest_framework/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ def is_simple_callable(obj):
"""
True if the object is a callable that takes no arguments.
"""
if not hasattr(inspect, 'signature'):
return py2k_is_simple_callable(obj)

if not callable(obj):
return False

sig = inspect.signature(obj)
params = sig.parameters.values()
return all(param.default != param.empty for param in params)


def py2k_is_simple_callable(obj):
function = inspect.isfunction(obj)
method = inspect.ismethod(obj)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,4 @@ def test_view(self):
}
}
)
self.assertEquals(schema, expected)
self.assertEqual(schema, expected)