|
14 | 14 | mmap = None |
15 | 15 |
|
16 | 16 | import struct |
17 | | -import ipaddress |
18 | 17 |
|
19 | | -from maxminddb.compat import byte_from_int, int_from_byte |
| 18 | +from maxminddb.compat import byte_from_int, int_from_byte, compat_ip_address |
20 | 19 | from maxminddb.const import MODE_AUTO, MODE_MMAP, MODE_FILE, MODE_MEMORY |
21 | 20 | from maxminddb.decoder import Decoder |
22 | 21 | from maxminddb.errors import InvalidDatabaseError |
@@ -47,7 +46,6 @@ def __init__(self, database, mode=MODE_AUTO): |
47 | 46 | * MODE_MEMORY - load database into memory. |
48 | 47 | * MODE_AUTO - tries MODE_MMAP and then MODE_FILE. Default. |
49 | 48 | """ |
50 | | - # pylint: disable=redefined-variable-type |
51 | 49 | if (mode == MODE_AUTO and mmap) or mode == MODE_MMAP: |
52 | 50 | with open(database, 'rb') as db_file: |
53 | 51 | self._buffer = mmap.mmap( |
@@ -95,10 +93,8 @@ def get(self, ip_address): |
95 | 93 | Arguments: |
96 | 94 | ip_address -- an IP address in the standard string notation |
97 | 95 | """ |
98 | | - if isinstance(ip_address, bytes): |
99 | | - ip_address = ip_address.decode() |
100 | 96 |
|
101 | | - address = ipaddress.ip_address(ip_address) |
| 97 | + address = compat_ip_address(ip_address) |
102 | 98 |
|
103 | 99 | if address.version == 6 and self._metadata.ip_version == 4: |
104 | 100 | raise ValueError('Error looking up {0}. You attempted to look up ' |
|
0 commit comments