File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,9 @@ What's New in astroid 2.6.2?
1212============================
1313Release date: TBA
1414
15+ * Fix a crash when the inference of the length of a node failed
1516
17+ Closes PyCQA/pylint#4633
1618
1719What's New in astroid 2.6.1?
1820============================
Original file line number Diff line number Diff line change @@ -290,14 +290,19 @@ def object_len(node, context=None):
290290 f"object of type '{ node_type .pytype ()} ' has no len()"
291291 ) from e
292292
293- result_of_len = next (len_call .infer_call_result (node , context ))
293+ inferred = len_call .infer_call_result (node , context )
294+ if inferred is util .Uninferable :
295+ raise InferenceError (node = node , context = context )
296+ result_of_len = next (inferred , None )
294297 if (
295298 isinstance (result_of_len , nodes .Const )
296299 and result_of_len .pytype () == "builtins.int"
297300 ):
298301 return result_of_len .value
299- if isinstance (result_of_len , bases .Instance ) and result_of_len .is_subtype_of (
300- "builtins.int"
302+ if (
303+ result_of_len is None
304+ or isinstance (result_of_len , bases .Instance )
305+ and result_of_len .is_subtype_of ("builtins.int" )
301306 ):
302307 # Fake a result as we don't know the arguments of the instance call.
303308 return 0
You can’t perform that action at this time.
0 commit comments