Changes between Initial Version and Version 1 of Ticket #37193
- Timestamp:
- Jun 28, 2026, 1:54:11 AM (3 weeks ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #37193 – Description
initial v1 1 1 django.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 {{{ 2 4 3 5 # django/contrib/gis/utils/ogrinfo.py 4 6 for j, feature in enumerate(layer[:num_features]): 5 7 ... 8 }}} 6 9 7 10 Because the value isn't validated, Python's slicing rules leak through and produce results that don't match what the parameter name implies: 8 11 12 {{{ 9 13 >>> from django.contrib.gis.utils import ogrinfo 10 14 >>> ogrinfo("cities.shp", num_features=None) # prints *every* feature, not none 11 15 >>> ogrinfo("cities.shp", num_features=-2) # prints all features except the last two 16 }}} 12 17 13 18 A caller reasonably expecting num_features to mean "how many features to show" gets neither an error nor the requested count.