aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2020-01-12 11:50:36 +0100
committerGravatar GitHub <[email protected]>2020-01-12 11:50:36 +0100
commita0e5eaeee1f0b3d243978ca53c618a55088b7152 (patch)
treedf751cafae80768dc7afa6c1a7fdc92f50d72bb2
parentUpdate Code Jam Participant ID (diff)
parentAdd handling for empty PEP metadata values (diff)
Merge pull request #721 from python-discord/pep-empty-field-fix
Add handling for empty PEP metadata values
Diffstat (limited to '')
-rw-r--r--bot/cogs/utils.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py
index 47a59db66..da278011a 100644
--- a/bot/cogs/utils.py
+++ b/bot/cogs/utils.py
@@ -62,14 +62,12 @@ class Utils(Cog):
pep_embed.set_thumbnail(url="https://www.python.org/static/opengraph-icon-200x200.png")
# Add the interesting information
- if "Status" in pep_header:
- pep_embed.add_field(name="Status", value=pep_header["Status"])
- if "Python-Version" in pep_header:
- pep_embed.add_field(name="Python-Version", value=pep_header["Python-Version"])
- if "Created" in pep_header:
- pep_embed.add_field(name="Created", value=pep_header["Created"])
- if "Type" in pep_header:
- pep_embed.add_field(name="Type", value=pep_header["Type"])
+ fields_to_check = ("Status", "Python-Version", "Created", "Type")
+ for field in fields_to_check:
+ # Check for a PEP metadata field that is present but has an empty value
+ # embed field values can't contain an empty string
+ if pep_header.get(field, ""):
+ pep_embed.add_field(name=field, value=pep_header[field])
elif response.status != 404:
# any response except 200 and 404 is expected