Repository: geopandas/geopandas

Issue:
BUG: exception was ignored while fetching the attribute __array_interface__
This issue is essentially described [here](https://gis.stackexchange.com/q/402987).

In a miniconda environment on any OS using a conda-forge channel with geopandas 0.9.0, shapely 1.7.1, pygeos 0.10.1 and numpy 1.21.0, take this example `test_numpy_dep.py` script:
```python
import geopandas
from random import random
from shapely.geometry import Polygon

geoms = [Polygon((random(), random()) for _ in range(3)) for _ in range(3)]
gdf = geopandas.GeoDataFrame(geometry=geoms)
```
and run it via `python -W all test_numpy_dep.py`. The console will be flooded one warning per geometry, each showing:
> C:\Users\mtoews\Miniconda3\envs\pyforge\lib\site-packages\geopandas\_vectorized.py:106: DeprecationWarning: An exception was ignored while fetching the attribute `__array_interface__` from an object of type 'Polygon'.  With the exception of `AttributeError` NumPy will always raise this exception in the future.  Raise this deprecation warning to see the original exception. (Warning added NumPy 1.21)

(similar on Linux, I'm just happen to be sitting at Windows desktop now).

The relevant [NumPy release note](https://github.com/numpy/numpy/releases/tag/v1.21.0) is titled "Exceptions will be raised during array-like creation". I'll admit I don't 100% follow the expected changes.

Note there is a related shapely deprecation warning, see #1659. Also, shapely 1.8 (not released yet) will [deprecate the array interface](https://github.com/Toblerity/Shapely/pull/955).

#### Output of ``geopandas.show_versions()``

<details>

```
SYSTEM INFO
-----------
python     : 3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:37:25) [MSC v.1916 64 bit (AMD64)]
executable : C:\Users\mtoews\Miniconda3\envs\pyforge\python.exe
machine    : Windows-10-10.0.17134-SP0

GEOS, GDAL, PROJ INFO
---------------------
GEOS       : None
GEOS lib   : None
GDAL       : 3.3.1
GDAL data dir: None
PROJ       : 8.0.1
PROJ data dir: C:\Users\mtoews\Miniconda3\envs\pyforge\Library\share\proj

PYTHON DEPENDENCIES
-------------------
geopandas  : 0.9.0
pandas     : 1.2.5
fiona      : 1.8.20
numpy      : 1.21.0
shapely    : 1.7.1
rtree      : 0.9.7
pyproj     : 3.1.0
matplotlib : 3.4.2
mapclassify: 2.4.2
geopy      : None
psycopg2   : 2.9.1 (dt dec pq3 ext lo64)
geoalchemy2: None
pyarrow    : None
pygeos     : 0.10.1
```
</details>



Discussion:
On further inspection, this issue may need to be fixed in Shapely, see https://github.com/Toblerity/Shapely/issues/1173
Thanks for the report! This shows up in our CI as well. 

The optimal solution would be to fast track shapely 2.0 but I understand that will not happen :). 

I guess the best way is to switch to `AttributError` as you suggest in Toblerity/Shapely#1173. I am not sure we can fix this on geopandas side.
This warning is also triggered in [geoutils](https://github.com/GlacioHack/GeoUtils.git) and [xdem](https://github.com/GlacioHack/xdem.git) (which depend on GeoPandas) where we get more warnings than usual 😉

![image](https://user-images.githubusercontent.com/33550973/127628339-dd8de9fb-48b6-4de8-a2f1-56859363ba42.png)


Resolving patch:
diff --git a/geopandas/_compat.py b/geopandas/_compat.py
--- a/geopandas/_compat.py
+++ b/geopandas/_compat.py
@@ -4,6 +4,7 @@
 import os
 import warnings
 
+import numpy as np
 import pandas as pd
 import pyproj
 import shapely
@@ -147,6 +148,19 @@ def ignore_shapely2_warnings():
             yield
 
 
+elif (str(np.__version__) >= LooseVersion("1.21")) and not SHAPELY_GE_20:
+
+    @contextlib.contextmanager
+    def ignore_shapely2_warnings():
+        with warnings.catch_warnings():
+            # warning from numpy for existing Shapely releases (this is fixed
+            # with Shapely 1.8)
+            warnings.filterwarnings(
+                "ignore", "An exception was ignored while fetching", DeprecationWarning
+            )
+            yield
+
+
 else:
 
     @contextlib.contextmanager
diff --git a/geopandas/array.py b/geopandas/array.py
--- a/geopandas/array.py
+++ b/geopandas/array.py
@@ -951,7 +951,8 @@ def _fill(self, idx, value):
             )
         # self.data[idx] = value
         value_arr = np.empty(1, dtype=object)
-        value_arr[:] = [value]
+        with compat.ignore_shapely2_warnings():
+            value_arr[:] = [value]
         self.data[idx] = value_arr
         return self
 


Test patch:
diff --git a/geopandas/tests/test_geoseries.py b/geopandas/tests/test_geoseries.py
--- a/geopandas/tests/test_geoseries.py
+++ b/geopandas/tests/test_geoseries.py
@@ -20,7 +20,7 @@
 from shapely.geometry.base import BaseGeometry
 
 from geopandas import GeoSeries, GeoDataFrame
-from geopandas._compat import PYPROJ_LT_3
+from geopandas._compat import PYPROJ_LT_3, ignore_shapely2_warnings
 from geopandas.array import GeometryArray, GeometryDtype
 from geopandas.testing import assert_geoseries_equal
 
@@ -439,7 +439,10 @@ def test_from_series(self):
             Polygon([(random.random(), random.random()) for _ in range(3)])
             for _ in range(10)
         ]
-        s = pd.Series(shapes, index=list("abcdefghij"), name="foo")
+        with ignore_shapely2_warnings():
+            # the warning here is not suppressed by GeoPandas, as this is a pure
+            # pandas construction call
+            s = pd.Series(shapes, index=list("abcdefghij"), name="foo")
         g = GeoSeries(s)
         check_geoseries(g)