Skip to content

[BUG] When run app() multiple times, categories list in output is wrong. #179

Open
@GuanHenan

Description

@GuanHenan

I find a bug in constants/element.py, line 42

def extract_categories(s, categories=None):
if categories == None:
categories = []

if s == None or len(s) == 0:
return categories
if len(s) >= 4 and type(s[0]) is str:
categories.append({"name": s[0], "id": s[2]})
else:
for sub in s:
extract_categories(sub, categories)
return categories

The problem is using list as the default parameter. It does not work as expected. It's recommended to use None as the default value and initialize the list inside the function if it's None.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions