From 86f61a990621797a6a9fe8cb67c2a88970b910b4 Mon Sep 17 00:00:00 2001 From: nramirezuy Date: Thu, 17 Jul 2014 19:07:13 -0300 Subject: [PATCH] get_func_args maximum recursion fix #728 --- scrapy/tests/test_utils_python.py | 1 + scrapy/utils/python.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/scrapy/tests/test_utils_python.py b/scrapy/tests/test_utils_python.py index 9122cf1be..be81dd26c 100644 --- a/scrapy/tests/test_utils_python.py +++ b/scrapy/tests/test_utils_python.py @@ -193,6 +193,7 @@ class UtilsPythonTestCase(unittest.TestCase): # TODO: how do we fix this to return the actual argument names? self.assertEqual(get_func_args(unicode.split), []) self.assertEqual(get_func_args(" ".join), []) + self.assertEqual(get_func_args(operator.itemgetter(2)), []) if __name__ == "__main__": unittest.main() diff --git a/scrapy/utils/python.py b/scrapy/utils/python.py index 6e03d2c12..551d337eb 100644 --- a/scrapy/utils/python.py +++ b/scrapy/utils/python.py @@ -147,6 +147,8 @@ def get_func_args(func, stripself=False): elif hasattr(func, '__call__'): if inspect.isroutine(func): return [] + elif getattr(func, '__name__', None) == '__call__': + return [] else: return get_func_args(func.__call__, True) else: