Changes between Initial Version and Version 1 of Ticket #37193


Ignore:
Timestamp:
Jun 28, 2026, 1:54:11 AM (3 weeks ago)
Author:
David Smith
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #37193 – Description

    initial v1  
    11django.contrib.gis.utils.ogrinfo(data_source, num_features=10) is documented (and named) as taking the number of features to display per layer. Internally, it passes the argument straight into a list slice:
     2
     3{{{
    24
    35# django/contrib/gis/utils/ogrinfo.py
    46for j, feature in enumerate(layer[:num_features]):
    57    ...
     8}}}
    69
    710Because the value isn't validated, Python's slicing rules leak through and produce results that don't match what the parameter name implies:
    811
     12{{{
    913>>> from django.contrib.gis.utils import ogrinfo
    1014>>> ogrinfo("cities.shp", num_features=None)   # prints *every* feature, not none
    1115>>> ogrinfo("cities.shp", num_features=-2)      # prints all features except the last two
     16}}}
    1217
    1318A caller reasonably expecting num_features to mean "how many features to show" gets neither an error nor the requested count.
Back to Top