Skip to content

3.3.0

Latest

Choose a tag to compare

@oschwald oschwald released this 17 Nov 21:45
Immutable release. Only release title and notes can be modified.
387caeb
  • Fixed iteration over an IPv6 database with a network shorter than /96
    whose first bits are zero, such as ::/1. The readers raised
    ValueError or skipped networks. The pure Python reader also raised
    ValueError for a network that starts at ::1:0:0, such as
    ::1:0:0/96.

  • The pure Python reader now raises InvalidDatabaseError for 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 raises InvalidDatabaseError. Previously, the C extension
    could corrupt memory, and the pure Python reader raised RecursionError
    or returned part of the networks.

  • A second __init__ on a pure Python Reader now closes the old
    database, and an iterator from before it raises ValueError, 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.
    After close(), an iterator raises ValueError in every mode.

  • The pure Python reader now raises InvalidDatabaseError when 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 InvalidDatabaseError when a record map
    key is not a string, as the C extension does. Previously, it returned the
    non-string key or raised TypeError.

  • The pure Python reader now raises InvalidDatabaseError for 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 InvalidDatabaseError in MODE_FILE,
    as in MODE_MEMORY. Previously, it raised OSError on platforms with
    os.pread.

  • C extension:

    • Fixed segmentation faults from invalid use of Metadata, Reader and
      the internal iterator type.
    • Fixed a segmentation fault on a database with a map key that is not a
      string. Such a database now raises InvalidDatabaseError.
    • Fixed large uint32 values, which came back negative on platforms
      with a 32-bit C long, such as Windows.
    • Fixed memory leaks and a use-after-free. A second __init__ on a
      Reader now closes the old database, and an iterator from before it
      raises ValueError. A failed __init__ keeps the old database.
      Reinitializing a Metadata changes nothing.
    • Fixed a RuntimeWarning or RuntimeError on free-threaded Python on
      macOS when a Reader failed to open or was used without __init__.
    • Fixed a deadlock on free-threaded Python when a Reader was 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 StopIteration after its Reader
      closes, not ValueError.
    • 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_size and search_tree_size properties to
      Metadata, as the pure Python Metadata has.
  • 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
      raised TypeError. It raises InvalidDatabaseError for 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 invalid ip_version or format version, a
      build_epoch of 0, or a string that is not UTF-8 anywhere in the
      metadata. Previously, the reader opened most of these files, and some
      raised TypeError or UnicodeDecodeError.
    • 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 C Reader.metadata() has the UnicodeDecodeError as its
      cause.
  • Added maxminddb.Mode, which the README already described.

  • Type checkers now reject a subscript of maxminddb.types.Record or
    Primitive, such as Record[str]. The subscript still works at
    runtime. Pull request by Adam Hitchcock. GitHub #464.

  • Type hints:

    • Primitive includes bytearray, which the C extension returns for
      the bytes type.
    • Reader.__iter__ declares its item type.
    • Added the StrOrBytesPath and DatabaseSource aliases to
      maxminddb.types.
    • The maxminddb.extension.Reader stub accepts only a path, as the
      extension does.
    • MODE_FD accepts any object whose read() method returns bytes,
      such as a gzip.GzipFile. maxminddb.types.SupportsRead describes
      this type.
  • MODE_AUTO now accepts a binary file object. Previously, it raised
    TypeError. It reads the file object into memory with the pure Python
    reader, as MODE_FD does. The C extension needs a path, so lookups are
    slower than with a path when the extension is installed.

  • The pure Python reader raises TypeError when the database argument does
    not suit the mode.

  • Updated the vendored libmaxminddb to 1.14.1. This fixes a build failure
    with -Werror on platforms where ssize_t is 32 bits, such as i686.