#35681: GeoIP2Exception does not work as advertised
------------------------------+--------------------------------------
Reporter: Jon Ribbens | Type: Bug
Status: new | Component: GIS
Version: 5.1 | Severity: Normal
Keywords: geoip geoip2 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+--------------------------------------
The `contrib.gis.geoip2` module describes `GeoIP2Exception` as being
"raised when an error occurs in a call to the underlying geoip2 library".
This is completely false - the code makes no attempt whatsoever to do
that. It is actually an exception raised when one of the extra checks that
the django code performs fails (e.g. if the `GEOIP_PATH` setting is
missing).
If the underlying `geoip2` module raises an exception then this is passed
directly through to the caller unchanged. If the caller wants to catch
exceptions from the `geoip2` module then they either have to catch
`Exception`, or violate the encapsulation by importing `geoip2.errors`
themselves.
I could provide a patch to fix this, but I would need to know what
peoples' attitude would be to backwards-compatibility. Would it be better
to make the code match the documentation by catching exceptions and re-
throwing them as `GeoIP2Exception`, or would it be better to add a new
`contrib.gis.geoip2.GeoIP2UnderlyingException` which is just an alias for
`geoip2.errors.GeoIP2Error`? The latter is ugly but the former could break
backwards compatibility.
--
Ticket URL: <https://code.djangoproject.com/ticket/35681>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107019151b1c166-78dce47e-0aa4-4768-895c-1d010b3650fb-000000%40eu-central-1.amazonses.com.