Repository navigation
-
Fixed iteration over an IPv6 database with a network shorter than /96
whose first bits are zero, such as::/1. The readers raised
ValueErroror skipped networks. The pure Python reader also raised
ValueErrorfor a network that starts at::1:0:0, such as
::1:0:0/96. -
The pure Python reader now raises
InvalidDatabaseErrorfor a search tree
record that points before the data section. Previously, it returned an
empty map. -
Iterating over a database with a corrupt search tree, such as one with a
cycle, now raisesInvalidDatabaseError. Previously, the C extension
could corrupt memory, and the pure Python reader raisedRecursionError
or returned part of the networks. -
A second
__init__on a pure PythonReadernow closes the old
database, and an iterator from before it raisesValueError, as in the
C extension. Before, the iterator walked the new database with node
numbers from the old one. A failed__init__keeps the old database.
Afterclose(), an iterator raisesValueErrorin every mode. -
The pure Python reader now raises
InvalidDatabaseErrorwhen a value,
search tree record or pointer goes past the end of the data section, or when
the search tree overlaps the metadata. Previously, it could return a shorter
or wrong value, or decode bytes from the metadata section. -
The pure Python reader now raises
InvalidDatabaseErrorwhen a record map
key is not a string, as the C extension does. Previously, it returned the
non-string key or raisedTypeError. -
The pure Python reader now raises
InvalidDatabaseErrorfor extended type
byte 0. Previously, it decoded the value as a map. The C extension still
decodes it as a map, because libmaxminddb does not check this byte. -
An empty database file now raises
InvalidDatabaseErrorinMODE_FILE,
as inMODE_MEMORY. Previously, it raisedOSErroron platforms with
os.pread. -
C extension:
- Fixed segmentation faults from invalid use of
Metadata,Readerand
the internal iterator type. - Fixed a segmentation fault on a database with a map key that is not a
string. Such a database now raisesInvalidDatabaseError. - Fixed large
uint32values, which came back negative on platforms
with a 32-bit Clong, such as Windows. - Fixed memory leaks and a use-after-free. A second
__init__on a
Readernow closes the old database, and an iterator from before it
raisesValueError. A failed__init__keeps the old database.
Reinitializing aMetadatachanges nothing. - Fixed a
RuntimeWarningorRuntimeErroron free-threaded Python on
macOS when aReaderfailed to open or was used without__init__. - Fixed a deadlock on free-threaded Python when a
Readerwas closed
during iteration, from another thread or from a signal handler. - Fixed a crash on free-threaded Python when two threads advanced the same
iterator. - An exhausted iterator now raises
StopIterationafter itsReader
closes, notValueError. - The iterator now stops after an error, as the pure Python iterator does.
This includes an error in the data of one record, but not a failure to
get the read lock. Previously, the next call returned the remaining
networks. - Added the
node_byte_sizeandsearch_tree_sizeproperties to
Metadata, as the pure PythonMetadatahas.
- Fixed segmentation faults from invalid use of
-
Metadata:
- The pure Python reader ignores unknown keys, which a new minor version of
the format can add, if their values decode. Previously, an unknown key
raisedTypeError. It raisesInvalidDatabaseErrorfor a missing key,
a key that is not a string, a value that is not of the expected Python
type or is out of range, an invalidip_versionor format version, a
build_epochof 0, or a string that is not UTF-8 anywhere in the
metadata. Previously, the reader opened most of these files, and some
raisedTypeErrororUnicodeDecodeError. - The C extension ignores unknown keys unless a value cannot be decoded,
such as a map with a key that is not a string. Previously,
Reader.metadata()crashed with a segmentation fault on any unknown
key. - For a metadata string that is not UTF-8, the
InvalidDatabaseError
from the CReader.metadata()has theUnicodeDecodeErroras its
cause.
- The pure Python reader ignores unknown keys, which a new minor version of
-
Added
maxminddb.Mode, which the README already described. -
Type checkers now reject a subscript of
maxminddb.types.Recordor
Primitive, such asRecord[str]. The subscript still works at
runtime. Pull request by Adam Hitchcock. GitHub #464. -
Type hints:
Primitiveincludesbytearray, which the C extension returns for
thebytestype.Reader.__iter__declares its item type.- Added the
StrOrBytesPathandDatabaseSourcealiases to
maxminddb.types. - The
maxminddb.extension.Readerstub accepts only a path, as the
extension does. MODE_FDaccepts any object whoseread()method returnsbytes,
such as agzip.GzipFile.maxminddb.types.SupportsReaddescribes
this type.
-
MODE_AUTOnow accepts a binary file object. Previously, it raised
TypeError. It reads the file object into memory with the pure Python
reader, asMODE_FDdoes. The C extension needs a path, so lookups are
slower than with a path when the extension is installed. -
The pure Python reader raises
TypeErrorwhen the database argument does
not suit the mode. -
Updated the vendored libmaxminddb to 1.14.1. This fixes a build failure
with-Werroron platforms wheressize_tis 32 bits, such as i686.