From 00ccda69584785fd22025a3f821e1c3437302eaa Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Wed, 30 Dec 2020 10:58:17 +0100 Subject: Fix a bug for dunder methods inference of function objects Fixes #819 --- tests/unittest_regrtest.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/unittest_regrtest.py b/tests/unittest_regrtest.py index 17668edd..b75e3dfe 100644 --- a/tests/unittest_regrtest.py +++ b/tests/unittest_regrtest.py @@ -343,5 +343,16 @@ def test_ancestor_looking_up_redefined_function(): assert isinstance(found[0], nodes.FunctionDef) +def test_crash_in_dunder_inference_prevented(): + code = """ + class MyClass(): + def fu(self, objects): + delitem = dict.__delitem__.__get__(self, dict) + delitem #@ + """ + inferred = next(extract_node(code).infer()) + assert "builtins.dict.__delitem__" == inferred.qname() + + if __name__ == "__main__": unittest.main() -- cgit v1.2.1