Skip to content

Commit 88a3b4c

Browse files
jubnzvdanmar
authored andcommitted
addons: Fix __repr__ methods (#2448)
This commit fixes __repr__ methods introduced in d538315. Fields that recursively links to other cppcheckdata objects was removed to avoid max recursion depth crash on printing.
1 parent c46e44e commit 88a3b4c

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

addons/cppcheckdata.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,13 @@ def __init__(self, element):
270270
self.column = int(element.get('column'))
271271

272272
def __repr__(self):
273-
attrs = ["Id", "str", "next", "previous", "scopeId",
274-
"scope", "isName", "isUnsigned", "isSigned",
275-
"isNumber", "isInt", "isFloat", "isString", "strlen",
276-
"isChar", "isOp", "isArithmeticalOp", "isComparisonOp",
277-
"isLogicalOp", "isExpandedMacro", "linkId", "link",
278-
"varId", "variableId", "variable", "functionId", "function",
279-
"valuesId", "values", "valueType", "typeScopeId", "typeScope",
280-
"astParentId", "astParent", "astOperand1Id", "astOperand1",
281-
"astOperand2Id", "astOperand2", "file", "linenr", "column"]
273+
attrs = ["Id", "str", "scopeId", "isName", "isUnsigned", "isSigned",
274+
"isNumber", "isInt", "isFloat", "isString", "strlen",
275+
"isChar", "isOp", "isArithmeticalOp", "isComparisonOp",
276+
"isLogicalOp", "isExpandedMacro", "linkId", "varId",
277+
"variableId", "functionId", "valuesId", "valueType",
278+
"typeScopeId", "astParentId", "astOperand1Id", "file",
279+
"linenr", "column"]
282280
return "{}({})".format(
283281
"Token",
284282
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
@@ -356,8 +354,7 @@ def __init__(self, element):
356354
'Switch', 'Try', 'Catch', 'Unconditional', 'Lambda'))
357355

358356
def __repr__(self):
359-
attrs = ["Id", "className", "functionId", "function",
360-
"bodyStartId", "bodyStart", "bodyEndId", "bodyEnd",
357+
attrs = ["Id", "className", "functionId", "bodyStartId", "bodyEndId",
361358
"nestedInId", "nestedIn", "type", "isExecutable"]
362359
return "{}({})".format(
363360
"Scope",
@@ -415,7 +412,7 @@ def __init__(self, element):
415412

416413
def __repr__(self):
417414
attrs = ["Id", "tokenDefId", "name", "type", "isVirtual",
418-
"isImplicitlyVirtual", "isStatic", "argument", "argumentId"]
415+
"isImplicitlyVirtual", "isStatic", "argumentId"]
419416
return "{}({})".format(
420417
"Function",
421418
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
@@ -500,11 +497,10 @@ def __init__(self, element):
500497
self.constness = int(self.constness)
501498

502499
def __repr__(self):
503-
attrs = ["Id", "nameTokenId", "nameToken", "typeStartTokenId",
504-
"typeStartToken", "typeEndTokenId", "typeEndToken",
505-
"access", "scopeId", "scope", "isArgument", "isArray",
506-
"isClass", "isConst", "isGlobal", "isExtern", "isLocal",
507-
"isPointer", "isReference", "isStatic", "constness", ]
500+
attrs = ["Id", "nameTokenId", "typeStartTokenId", "typeEndTokenId",
501+
"access", "scopeId", "isArgument", "isArray", "isClass",
502+
"isConst", "isGlobal", "isExtern", "isLocal", "isPointer",
503+
"isReference", "isStatic", "constness", ]
508504
return "{}({})".format(
509505
"Variable",
510506
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
@@ -736,8 +732,7 @@ def __init__(self, confignode):
736732
variable.setId(IdMap)
737733

738734
def __repr__(self):
739-
attrs = ["name", "directives", "tokenlist",
740-
"scopes", "functions", "variables", "valueflow"]
735+
attrs = ["name"]
741736
return "{}({})".format(
742737
"Configuration",
743738
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
@@ -885,7 +880,7 @@ def __init__(self, filename):
885880
self.configurations.append(Configuration(cfgnode))
886881

887882
def __repr__(self):
888-
attrs = ["configurations", ]
883+
attrs = ["configurations", "platform"]
889884
return "{}({})".format(
890885
"CppcheckData",
891886
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))

0 commit comments

Comments
 (0)