Skip to content

Commit

Permalink
fix: handle countries not recognized by geoip2 DB
Browse files Browse the repository at this point in the history
The `geoip2` library returns `None` when it only identifies the continent
related to the IP address.
  • Loading branch information
Agrendalath committed Feb 7, 2024
1 parent d9ab77c commit 43fbbf6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/geoinfo/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def country_code_from_ip(ip_addr: str) -> str:
try:
response = reader.country(ip_addr)
# pylint: disable=no-member
country_code = response.country.iso_code
country_code = response.country.iso_code or ""
except geoip2.errors.AddressNotFoundError:
country_code = ""
reader.close()
Expand Down

0 comments on commit 43fbbf6

Please sign in to comment.