We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 17a155b commit 8cd9d62Copy full SHA for 8cd9d62
maxminddb/decoder.py
@@ -125,13 +125,15 @@ def decode(self, offset):
125
if not type_num:
126
(type_num, new_offset) = self._read_extended(new_offset)
127
128
- if type_num not in self._type_decoder:
+ try:
129
+ decoder = self._type_decoder[type_num]
130
+ except KeyError:
131
raise InvalidDatabaseError('Unexpected type number ({type}) '
132
'encountered'.format(type=type_num))
133
134
(size, new_offset) = self._size_from_ctrl_byte(ctrl_byte, new_offset,
135
type_num)
- return self._type_decoder[type_num](self, size, new_offset)
136
+ return decoder(self, size, new_offset)
137
138
def _read_extended(self, offset):
139
(next_byte, ) = struct.unpack(b'!B', self._buffer[offset:offset + 1])
0 commit comments