Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#20389 closed Bug (fixed)

TypeError when executing example code of GeoIP

Reported by: anonymous Owned by: nobody
Component: Python 3 Version: 1.5
Severity: Normal Keywords: geoip TypeError
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I tried to execute example code from [1] and i found a TypeError on the line'').

You can see the traceback here in [2].

I'm using Python 3.2.3 and Django 1.5.1.


Change History (6)

comment:1 Changed 6 years ago by Aymeric Augustin

Component: UncategorizedPython 3
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

I'm copying the paste here before it expires:

    $ python3 shell
    Python 3.2.3 (default, May  6 2013, 01:46:35)
    [GCC 4.7.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from django.contrib.gis.geoip import GeoIP
    >>> g = GeoIP()
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "/usr/local/lib/python3.2/dist-packages/django/contrib/gis/geoip/", line 194, in country
        return {'country_code' : self.country_code(query),
      File "/usr/local/lib/python3.2/dist-packages/django/contrib/gis/geoip/", line 169, in country_code
        if ipv4_re.match(query):
    TypeError: can't use a string pattern on a bytes-like object

Thanks for the report. Most likely this feature isn't tested and it slipped through when we ported Django to Python 3.

comment:2 Changed 6 years ago by Claude Paroz

Resolution: fixed
Status: newclosed

I just fixed this this morning: [7b00d90208e998debc60e51cadb352645c91e3fd]

comment:3 Changed 5 years ago by anonymous

Resolution: fixed
Status: closednew

I'm the original reporter. The bug is still in django 1.5.2 as reported 3 months ago.

comment:4 Changed 5 years ago by Aymeric Augustin

Resolution: fixed
Status: newclosed

It's fixed in master and in 1.6.

comment:5 Changed 5 years ago by anonymous

aaugustin can you please point to the commit that fixes the problem so I can copy it?

comment:6 Changed 5 years ago by Aymeric Augustin

There's a link in comment 2 which closed the ticket.

Note: See TracTickets for help on using tickets.
Back to Top