Skip to content

Commit

Permalink
Merge branch 'maint-1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Gillies committed Jan 13, 2017
2 parents 491abc8 + 1d651c5 commit 2c8f049
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 16 deletions.
17 changes: 17 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ Changes

All issue numbers are relative to https://github.com/Toblerity/Fiona/issues.

1.7.2 (soon)
------------

Future Deprecation:

- `Collection.__next__()` is buggy in that it can lead to duplication of
features when used in combination with `Collection.filter()` or
`Collection.__iter__()`. It will be removed in Fiona 2.0. Please check for
usage of this deprecated feature by running your tests or programs with
`PYTHONWARNINGS="always:::fiona"` or `-W"always:::fiona"` and switch from
`next(collection)` to `next(iter(collection))` (#301).

1.7.1.post1 (2016-12-23)
------------------------
- New binary wheels using version 1.2.0 of sgillies/frs-wheel-builds. See
https://github.com/sgillies/frs-wheel-builds/blob/master/CHANGES.txt.

1.7.1 (2016-11-16)
------------------

Expand Down
2 changes: 1 addition & 1 deletion fiona/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@


__all__ = ['bounds', 'listlayers', 'open', 'prop_type', 'prop_width']
__version__ = "1.7.1"
__version__ = "1.7.2"
__gdal_version__ = get_gdal_release_name().decode('utf-8')

log = logging.getLogger('Fiona')
Expand Down
4 changes: 4 additions & 0 deletions fiona/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


import os
import warnings

from fiona import compat
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
Expand Down Expand Up @@ -311,6 +312,9 @@ def __iter__(self):

def __next__(self):
"""Returns next record from iterator."""
warnings.warn("Collection.__next__() is buggy and will be removed in "
"Fiona 2.0. Switch to `next(iter(collection))`.",
DeprecationWarning, stacklevel=2)
if not self.iterator:
iter(self)
return next(self.iterator)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bigint.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def testCreateBigIntSchema(self):

with fiona.open(name) as src:
if get_gdal_version_num() >= calc_gdal_version_num(2, 0, 0):
first = next(src)
first = next(iter(src))
self.assertEqual(first['properties'][fieldname], a_bigint)


Expand Down
12 changes: 6 additions & 6 deletions tests/test_multiconxn.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def test_meta(self):
self.assertEqual(sorted(self.c.schema.items()), sorted(c2.schema.items()))

def test_meta(self):
f1 = next(self.c)
f1 = next(iter(self.c))
with fiona.open("tests/data/coutwildrnp.shp", "r", layer="coutwildrnp") as c2:
f2 = next(c2)
f2 = next(iter(c2))
self.assertEqual(f1, f2)

@pytest.mark.skipif(FIXME_WINDOWS,
Expand Down Expand Up @@ -70,14 +70,14 @@ def test_meta(self):

def test_read(self):
c2 = fiona.open(os.path.join(self.tempdir, "multi_write_test.shp"), "r")
f2 = next(c2)
f2 = next(iter(c2))
del f2['id']
self.assertEqual(self.f, f2)

def test_read_after_close(self):
c2 = fiona.open(os.path.join(self.tempdir, "multi_write_test.shp"), "r")
self.c.close()
f2 = next(c2)
f2 = next(iter(c2))
del f2['id']
self.assertEqual(self.f, f2)

Expand Down Expand Up @@ -119,13 +119,13 @@ def test_meta(self):

def test_read(self):
c2 = fiona.open(os.path.join(self.dir, "write_test.shp"), "r")
f2 = next(c2)
f2 = next(iter(c2))
del f2['id']
self.assertEqual(self.f, f2)

def test_read_after_close(self):
c2 = fiona.open(os.path.join(self.dir, "write_test.shp"), "r")
self.c.close()
f2 = next(c2)
f2 = next(iter(c2))
del f2['id']
self.assertEqual(self.f, f2)
6 changes: 3 additions & 3 deletions tests/test_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_read_json_object_properties():
f.write(data)

with fiona.open(filename) as src:
ftr = next(src)
ftr = next(iter(src))
props = ftr['properties']
assert props['upperLeftCoordinate']['latitude'] == 45.66894
assert props['upperLeftCoordinate']['longitude'] == 87.91166
Expand Down Expand Up @@ -146,7 +146,7 @@ def test_write_json_object_properties():
dst.write(data)

with fiona.open(filename) as src:
ftr = next(src)
ftr = next(iter(src))
props = ftr['properties']
assert props['upperLeftCoordinate']['latitude'] == 45.66894
assert props['upperLeftCoordinate']['longitude'] == 87.91166
Expand Down Expand Up @@ -187,7 +187,7 @@ def test_json_prop_decode_non_geojson_driver():
dst.write(feature)

with fiona.open(filename) as src:
actual = next(src)
actual = next(iter(src))

assert isinstance(actual['properties']['ulc'], text_type)
a = json.loads(actual['properties']['ulc'])
Expand Down
4 changes: 2 additions & 2 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_schema(self):
('INTPTLON10', 'str:80'),
('GEOID10', 'str:80'),
('Decommisio', 'str:80')]) )
f = next(c)
f = next(iter(c))
self.assertEqual(f['properties']['EstimatedP'], 27773.0)


Expand Down Expand Up @@ -153,7 +153,7 @@ def test_issue177(self):
dst.write(rec)

with fiona.open(name) as src:
first = next(src)
first = next(iter(src))
assert first['geometry'] == {'type': 'Point', 'coordinates': (0, 0)}
assert first['properties']['a_fieldnam'] == 3.0

Expand Down
6 changes: 3 additions & 3 deletions tests/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_write_mismatch(self):
'num': 0}}])

with fiona.open(os.path.join(self.tempdir), encoding='latin1') as c:
f = next(c)
f = next(iter(c))
# Next assert fails.
self.assertEqual(f['properties']['label'], u'徐汇区')

Expand All @@ -105,7 +105,7 @@ def test_write_utf8(self):
'label': u'Ba\u2019kelalan', u'verit\xe9': 0}}])

with fiona.open(os.path.join(self.tempdir), encoding='utf-8') as c:
f = next(c)
f = next(iter(c))
self.assertEqual(f['properties']['label'], u'Ba\u2019kelalan')
self.assertEqual(f['properties'][u'verit\xe9'], 0)

Expand All @@ -123,6 +123,6 @@ def test_write_gb18030(self):
'properties': {'label': u'徐汇区', 'num': 0}}])

with fiona.open(os.path.join(self.tempdir), encoding='gb18030') as c:
f = next(c)
f = next(iter(c))
self.assertEqual(f['properties']['label'], u'徐汇区')
self.assertEqual(f['properties']['num'], 0)

0 comments on commit 2c8f049

Please sign in to comment.