Opened 6 years ago

Last modified 5 years ago

#30461 closed New feature

contrib.gis.geoip2 does not support pathlib.Path as GEOIP_PATH parameter, only str — at Version 1

Reported by: Nikita Krokosh Owned by: nobody
Component: GIS Version: dev
Severity: Normal Keywords: geoip2
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Nikita Krokosh)

I want to pass Path instance directly as GEOIP_PATH param but currently it only allowes str instances.
As I understand, min Python version for Django 2.2 is 3.5+ so I can freely pass Path instance there.

...
        # Getting the GeoIP data path.
        path = path or GEOIP_SETTINGS['GEOIP_PATH']
        if not path:
            raise GeoIP2Exception('GeoIP path must be provided via parameter or the GEOIP_PATH setting.')
        if not isinstance(path, str):
            raise TypeError('Invalid path type: %s' % type(path).__name__)

        path = Path(path)
...

I've fixed this issue myself.
https://github.com/lsnk/django/tree/ticket_30461_2_2
https://github.com/django/django/pull/11341

Change History (1)

comment:1 by Nikita Krokosh, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top