Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions mcstatus/pinger.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,13 @@ def __init__(self, raw):

if "description" not in raw:
raise ValueError("Invalid status object (no 'description' value)")
self.description = raw["description"]
self.description_clean = re.sub(r'\u00A7.', '', raw["description"])
if "text" not in raw["description"]:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this attempt to subscript the value if raw["description"] was a string that contained the word "text"? I think an explicit type check may be safer in this case

self.description = raw["description"]
else:
self.description = raw["description"]["text"]

self.description_clean = re.sub(r'\u00A7.', '', self.description)


if "favicon" in raw:
self.favicon = raw["favicon"]
Expand Down