Skip to content

Commit

Permalink
Fix NameError exception in check_tags()
Browse files Browse the repository at this point in the history
- Fixes two undefined variables error.
- Check the `tags` field of the `item` variable, previous code check
the `dt` variable which is the main dictionary data. And because en
extractor doesn't have `tags` in the main dictionary, this error is
not caught in test.
  • Loading branch information
xxyzz committed Feb 28, 2024
1 parent bd347c0 commit 42953d1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/wiktextract/wiktionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def check_tags(
item: dict
) -> None:
assert isinstance(item, dict)
tags = dt.get("tags")
tags = item.get("tags")
if tags is None:
return
if not isinstance(tags, (list, tuple)):
Expand All @@ -211,7 +211,9 @@ def check_tags(
# XXX enable the following later (currently too many bogus tags in
# non-English editions). Tag values should be standardized across
# editions, except for uppercase tags (e.g., regional variants).
if wtp.lang_code in ("en",): # Check edition
if wxr.wtp.lang_code in ("en",): # Check edition
from .tags import valid_tags

if tag not in valid_tags:
check_error(wxr, dt, word, lang, pos,
"invalid tag {} not in valid_tags (or "
Expand Down

0 comments on commit 42953d1

Please sign in to comment.