-
-
Notifications
You must be signed in to change notification settings - Fork 91
catch image=None in _retryer() #252
Copy link
Copy link
Open
Description
Follow-up from #247
There are still Nonetype related errors after fixing #248.
When array[0] is None, the code fails on line 682 with an AttributeError:
/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/contextily/plotting.py:134: in add_basemap
image, extent = bounds2img(
/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/contextily/tile.py:287: in bounds2img
merged, extent = _merge_tiles(tiles, arrays)
/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/site-packages/contextily/tile.py:682: in _merge_tiles
h, w, d = arrays[0].shape
E AttributeError: 'NoneType' object has no attribute 'shape'
If the first array is valid, but any of the other arrays is None, the issue surfaces a bit lower as a TypeError:
/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/contextily/plotting.py:134: in add_basemap
image, extent = bounds2img(
/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/contextily/tile.py:287: in bounds2img
merged, extent = _merge_tiles(tiles, arrays)
/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/contextily/tile.py:692: in _merge_tiles
img[y * h : (y + 1) * h, x * w : (x + 1) * w, :] = arr
E TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
I cannot fully grasp what is happening here. I imagined that image=None, and was looking at this part of the code:
Lines 454 to 457 in 0e38541
| with io.BytesIO(request.content) as image_stream: | |
| image = Image.open(image_stream).convert("RGBA") | |
| array = np.asarray(image) | |
| image.close() |
So I guess that would lead to this minimal example:
import numpy as np
image = None
array = np.asarray(image)
print(array.shape)However, this prints () and does not give the error above. @martinfleis do you have an idea how the image variable looks like when this error occurs? Or is my minimal reproduction example faulty?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels