prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Deprecation Warning with fiona 1.8b1
  using a `debian:buster` docker image
  
  installed Fiona with 
  > pip install git+https://github.com/Toblerity/Fiona.git@1.8b1
  
  I got this __warning__ today: 
  ```python
  /usr/local/lib/python2.7/dist-packages/geopandas/io/file.py:108: FionaDeprecationWarning: Use fiona.Env() instead.
    with fiona.drivers():
  No handlers could be found for logger "rasterio._gdal"
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `geopandas/io/file.py`
  Content:
  ```
  1 import os
  2 
  3 import fiona
  4 import numpy as np
  5 import six
  6 
  7 from geopandas import GeoDataFrame, GeoSeries
  8 
  9 # Adapted from pandas.io.common
  10 if six.PY3:
  11     from urllib.request import urlopen as _urlopen
  12     from urllib.parse import urlparse as parse_url
  13     from urllib.parse import uses_relative, uses_netloc, uses_params
  14 else:
  15     from urllib2 import urlopen as _urlopen
  16     from urlparse import urlparse as parse_url
  17     from urlparse import uses_relative, uses_netloc, uses_params
  18 
  19 _VALID_URLS = set(uses_relative + uses_netloc + uses_params)
  20 _VALID_URLS.discard('')
  21 
  22 
  23 def _is_url(url):
  24     """Check to see if *url* has a valid protocol."""
  25     try:
  26         return parse_url(url).scheme in _VALID_URLS
  27     except:
  28         return False
  29 
  30 
  31 def read_file(filename, bbox=None, **kwargs):
  32     """
  33     Returns a GeoDataFrame from a file or URL.
  34 
  35     Parameters
  36     ----------
  37     filename: str
  38         Either the absolute or relative path to the file or URL to
  39         be opened.
  40     bbox : tuple | GeoDataFrame or GeoSeries, default None
  41         Filter features by given bounding box, GeoSeries, or GeoDataFrame.
  42         CRS mis-matches are resolved if given a GeoSeries or GeoDataFrame.
  43     **kwargs:
  44         Keyword args to be passed to the `open` or `BytesCollection` method
  45         in the fiona library when opening the file. For more information on
  46         possible keywords, type:
  47         ``import fiona; help(fiona.open)``
  48 
  49     Examples
  50     --------
  51     >>> df = geopandas.read_file("nybb.shp")
  52 
  53     Returns
  54     -------
  55     geodataframe : GeoDataFrame
  56     """
  57     if _is_url(filename):
  58         req = _urlopen(filename)
  59         path_or_bytes = req.read()
  60         reader = fiona.BytesCollection
  61     else:
  62         path_or_bytes = filename
  63         reader = fiona.open
  64 
  65     with reader(path_or_bytes, **kwargs) as features:
  66         crs = features.crs
  67         if bbox is not None:
  68             if isinstance(bbox, GeoDataFrame) or isinstance(bbox, GeoSeries):
  69                 bbox = tuple(bbox.to_crs(crs).total_bounds)
  70             assert len(bbox) == 4
  71             f_filt = features.filter(bbox=bbox)
  72         else:
  73             f_filt = features
  74 
  75         columns = list(features.meta["schema"]["properties"]) + ["geometry"]
  76         gdf = GeoDataFrame.from_features(f_filt, crs=crs, columns=columns)
  77 
  78     return gdf
  79 
  80 
  81 def to_file(df, filename, driver="ESRI Shapefile", schema=None,
  82             **kwargs):
  83     """
  84     Write this GeoDataFrame to an OGR data source
  85 
  86     A dictionary of supported OGR providers is available via:
  87     >>> import fiona
  88     >>> fiona.supported_drivers
  89 
  90     Parameters
  91     ----------
  92     df : GeoDataFrame to be written
  93     filename : string
  94         File path or file handle to write to.
  95     driver : string, default 'ESRI Shapefile'
  96         The OGR format driver used to write the vector file.
  97     schema : dict, default None
  98         If specified, the schema dictionary is passed to Fiona to
  99         better control how the file is written. If None, GeoPandas
  100         will determine the schema based on each column's dtype
  101 
  102     The *kwargs* are passed to fiona.open and can be used to write
  103     to multi-layer data, store data within archives (zip files), etc.
  104     """
  105     if schema is None:
  106         schema = infer_schema(df)
  107     filename = os.path.abspath(os.path.expanduser(filename))
  108     with fiona.drivers():
  109         with fiona.open(filename, 'w', driver=driver, crs=df.crs,
  110                         schema=schema, **kwargs) as colxn:
  111             colxn.writerecords(df.iterfeatures())
  112 
  113 
  114 def infer_schema(df):
  115     try:
  116         from collections import OrderedDict
  117     except ImportError:
  118         from ordereddict import OrderedDict
  119 
  120     def convert_type(column, in_type):
  121         if in_type == object:
  122             return 'str'
  123         out_type = type(np.asscalar(np.zeros(1, in_type))).__name__
  124         if out_type == 'long':
  125             out_type = 'int'
  126         if out_type == 'bool':
  127             raise ValueError('column "{}" is boolean type, '.format(column) +
  128                              'which is unsupported in file writing. '
  129                              'Consider casting the column to int type.')
  130         return out_type
  131 
  132     properties = OrderedDict([
  133         (col, convert_type(col, _type)) for col, _type in
  134         zip(df.columns, df.dtypes) if col != df._geometry_column_name
  135     ])
  136 
  137     if df.empty:
  138         raise ValueError("Cannot write empty DataFrame to file.")
  139 
  140     geom_type = _common_geom_type(df)
  141     
  142     if not geom_type:
  143         raise ValueError("Geometry column cannot contain mutiple "
  144                          "geometry types when writing to file.")
  145 
  146     schema = {'geometry': geom_type, 'properties': properties}
  147 
  148     return schema
  149 
  150 
  151 def _common_geom_type(df):
  152     # Need to check geom_types before we write to file...
  153     # Some (most?) providers expect a single geometry type:
  154     # Point, LineString, or Polygon
  155     geom_types = df.geometry.geom_type.unique()
  156 
  157     from os.path import commonprefix
  158     # use reversed geom types and commonprefix to find the common suffix,
  159     # then reverse the result to get back to a geom type
  160     geom_type = commonprefix([g[::-1] for g in geom_types if g])[::-1]
  161     if not geom_type:
  162         return None
  163 
  164     if df.geometry.has_z.any():
  165         geom_type = "3D " + geom_type
  166 
  167     return geom_type
  168
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/geopandas/io/file.py b/geopandas/io/file.py
  --- a/geopandas/io/file.py
  +++ b/geopandas/io/file.py
  @@ -4,6 +4,11 @@
   import numpy as np
   import six
   
  +try:
  +    from fiona import Env as fiona_env
  +except ImportError:
  +    from fiona import drivers as fiona_env
  +
   from geopandas import GeoDataFrame, GeoSeries
   
   # Adapted from pandas.io.common
  @@ -105,7 +110,7 @@
       if schema is None:
           schema = infer_schema(df)
       filename = os.path.abspath(os.path.expanduser(filename))
  -    with fiona.drivers():
  +    with fiona_env():
           with fiona.open(filename, 'w', driver=driver, crs=df.crs,
                           schema=schema, **kwargs) as colxn:
               colxn.writerecords(df.iterfeatures())
  
verification_info: {"golden_diff": "diff --git a/geopandas/io/file.py b/geopandas/io/file.py\n--- a/geopandas/io/file.py\n+++ b/geopandas/io/file.py\n@@ -4,6 +4,11 @@\n import numpy as np\n import six\n \n+try:\n+    from fiona import Env as fiona_env\n+except ImportError:\n+    from fiona import drivers as fiona_env\n+\n from geopandas import GeoDataFrame, GeoSeries\n \n # Adapted from pandas.io.common\n@@ -105,7 +110,7 @@\n     if schema is None:\n         schema = infer_schema(df)\n     filename = os.path.abspath(os.path.expanduser(filename))\n-    with fiona.drivers():\n+    with fiona_env():\n         with fiona.open(filename, 'w', driver=driver, crs=df.crs,\n                         schema=schema, **kwargs) as colxn:\n             colxn.writerecords(df.iterfeatures())\n", "issue": "Deprecation Warning with fiona 1.8b1\nusing a `debian:buster` docker image\r\n\r\ninstalled Fiona with \r\n> pip install git+https://github.com/Toblerity/Fiona.git@1.8b1\r\n\r\nI got this __warning__ today: \r\n```python\r\n/usr/local/lib/python2.7/dist-packages/geopandas/io/file.py:108: FionaDeprecationWarning: Use fiona.Env() instead.\r\n  with fiona.drivers():\r\nNo handlers could be found for logger \"rasterio._gdal\"\r\n```\n", "before_files": [{"content": "import os\n\nimport fiona\nimport numpy as np\nimport six\n\nfrom geopandas import GeoDataFrame, GeoSeries\n\n# Adapted from pandas.io.common\nif six.PY3:\n    from urllib.request import urlopen as _urlopen\n    from urllib.parse import urlparse as parse_url\n    from urllib.parse import uses_relative, uses_netloc, uses_params\nelse:\n    from urllib2 import urlopen as _urlopen\n    from urlparse import urlparse as parse_url\n    from urlparse import uses_relative, uses_netloc, uses_params\n\n_VALID_URLS = set(uses_relative + uses_netloc + uses_params)\n_VALID_URLS.discard('')\n\n\ndef _is_url(url):\n    \"\"\"Check to see if *url* has a valid protocol.\"\"\"\n    try:\n        return parse_url(url).scheme in _VALID_URLS\n    except:\n        return False\n\n\ndef read_file(filename, bbox=None, **kwargs):\n    \"\"\"\n    Returns a GeoDataFrame from a file or URL.\n\n    Parameters\n    ----------\n    filename: str\n        Either the absolute or relative path to the file or URL to\n        be opened.\n    bbox : tuple | GeoDataFrame or GeoSeries, default None\n        Filter features by given bounding box, GeoSeries, or GeoDataFrame.\n        CRS mis-matches are resolved if given a GeoSeries or GeoDataFrame.\n    **kwargs:\n        Keyword args to be passed to the `open` or `BytesCollection` method\n        in the fiona library when opening the file. For more information on\n        possible keywords, type:\n        ``import fiona; help(fiona.open)``\n\n    Examples\n    --------\n    >>> df = geopandas.read_file(\"nybb.shp\")\n\n    Returns\n    -------\n    geodataframe : GeoDataFrame\n    \"\"\"\n    if _is_url(filename):\n        req = _urlopen(filename)\n        path_or_bytes = req.read()\n        reader = fiona.BytesCollection\n    else:\n        path_or_bytes = filename\n        reader = fiona.open\n\n    with reader(path_or_bytes, **kwargs) as features:\n        crs = features.crs\n        if bbox is not None:\n            if isinstance(bbox, GeoDataFrame) or isinstance(bbox, GeoSeries):\n                bbox = tuple(bbox.to_crs(crs).total_bounds)\n            assert len(bbox) == 4\n            f_filt = features.filter(bbox=bbox)\n        else:\n            f_filt = features\n\n        columns = list(features.meta[\"schema\"][\"properties\"]) + [\"geometry\"]\n        gdf = GeoDataFrame.from_features(f_filt, crs=crs, columns=columns)\n\n    return gdf\n\n\ndef to_file(df, filename, driver=\"ESRI Shapefile\", schema=None,\n            **kwargs):\n    \"\"\"\n    Write this GeoDataFrame to an OGR data source\n\n    A dictionary of supported OGR providers is available via:\n    >>> import fiona\n    >>> fiona.supported_drivers\n\n    Parameters\n    ----------\n    df : GeoDataFrame to be written\n    filename : string\n        File path or file handle to write to.\n    driver : string, default 'ESRI Shapefile'\n        The OGR format driver used to write the vector file.\n    schema : dict, default None\n        If specified, the schema dictionary is passed to Fiona to\n        better control how the file is written. If None, GeoPandas\n        will determine the schema based on each column's dtype\n\n    The *kwargs* are passed to fiona.open and can be used to write\n    to multi-layer data, store data within archives (zip files), etc.\n    \"\"\"\n    if schema is None:\n        schema = infer_schema(df)\n    filename = os.path.abspath(os.path.expanduser(filename))\n    with fiona.drivers():\n        with fiona.open(filename, 'w', driver=driver, crs=df.crs,\n                        schema=schema, **kwargs) as colxn:\n            colxn.writerecords(df.iterfeatures())\n\n\ndef infer_schema(df):\n    try:\n        from collections import OrderedDict\n    except ImportError:\n        from ordereddict import OrderedDict\n\n    def convert_type(column, in_type):\n        if in_type == object:\n            return 'str'\n        out_type = type(np.asscalar(np.zeros(1, in_type))).__name__\n        if out_type == 'long':\n            out_type = 'int'\n        if out_type == 'bool':\n            raise ValueError('column \"{}\" is boolean type, '.format(column) +\n                             'which is unsupported in file writing. '\n                             'Consider casting the column to int type.')\n        return out_type\n\n    properties = OrderedDict([\n        (col, convert_type(col, _type)) for col, _type in\n        zip(df.columns, df.dtypes) if col != df._geometry_column_name\n    ])\n\n    if df.empty:\n        raise ValueError(\"Cannot write empty DataFrame to file.\")\n\n    geom_type = _common_geom_type(df)\n    \n    if not geom_type:\n        raise ValueError(\"Geometry column cannot contain mutiple \"\n                         \"geometry types when writing to file.\")\n\n    schema = {'geometry': geom_type, 'properties': properties}\n\n    return schema\n\n\ndef _common_geom_type(df):\n    # Need to check geom_types before we write to file...\n    # Some (most?) providers expect a single geometry type:\n    # Point, LineString, or Polygon\n    geom_types = df.geometry.geom_type.unique()\n\n    from os.path import commonprefix\n    # use reversed geom types and commonprefix to find the common suffix,\n    # then reverse the result to get back to a geom type\n    geom_type = commonprefix([g[::-1] for g in geom_types if g])[::-1]\n    if not geom_type:\n        return None\n\n    if df.geometry.has_z.any():\n        geom_type = \"3D \" + geom_type\n\n    return geom_type\n", "path": "geopandas/io/file.py"}], "after_files": [{"content": "import os\n\nimport fiona\nimport numpy as np\nimport six\n\ntry:\n    from fiona import Env as fiona_env\nexcept ImportError:\n    from fiona import drivers as fiona_env\n\nfrom geopandas import GeoDataFrame, GeoSeries\n\n# Adapted from pandas.io.common\nif six.PY3:\n    from urllib.request import urlopen as _urlopen\n    from urllib.parse import urlparse as parse_url\n    from urllib.parse import uses_relative, uses_netloc, uses_params\nelse:\n    from urllib2 import urlopen as _urlopen\n    from urlparse import urlparse as parse_url\n    from urlparse import uses_relative, uses_netloc, uses_params\n\n_VALID_URLS = set(uses_relative + uses_netloc + uses_params)\n_VALID_URLS.discard('')\n\n\ndef _is_url(url):\n    \"\"\"Check to see if *url* has a valid protocol.\"\"\"\n    try:\n        return parse_url(url).scheme in _VALID_URLS\n    except:\n        return False\n\n\ndef read_file(filename, bbox=None, **kwargs):\n    \"\"\"\n    Returns a GeoDataFrame from a file or URL.\n\n    Parameters\n    ----------\n    filename: str\n        Either the absolute or relative path to the file or URL to\n        be opened.\n    bbox : tuple | GeoDataFrame or GeoSeries, default None\n        Filter features by given bounding box, GeoSeries, or GeoDataFrame.\n        CRS mis-matches are resolved if given a GeoSeries or GeoDataFrame.\n    **kwargs:\n        Keyword args to be passed to the `open` or `BytesCollection` method\n        in the fiona library when opening the file. For more information on\n        possible keywords, type:\n        ``import fiona; help(fiona.open)``\n\n    Examples\n    --------\n    >>> df = geopandas.read_file(\"nybb.shp\")\n\n    Returns\n    -------\n    geodataframe : GeoDataFrame\n    \"\"\"\n    if _is_url(filename):\n        req = _urlopen(filename)\n        path_or_bytes = req.read()\n        reader = fiona.BytesCollection\n    else:\n        path_or_bytes = filename\n        reader = fiona.open\n\n    with reader(path_or_bytes, **kwargs) as features:\n        crs = features.crs\n        if bbox is not None:\n            if isinstance(bbox, GeoDataFrame) or isinstance(bbox, GeoSeries):\n                bbox = tuple(bbox.to_crs(crs).total_bounds)\n            assert len(bbox) == 4\n            f_filt = features.filter(bbox=bbox)\n        else:\n            f_filt = features\n\n        columns = list(features.meta[\"schema\"][\"properties\"]) + [\"geometry\"]\n        gdf = GeoDataFrame.from_features(f_filt, crs=crs, columns=columns)\n\n    return gdf\n\n\ndef to_file(df, filename, driver=\"ESRI Shapefile\", schema=None,\n            **kwargs):\n    \"\"\"\n    Write this GeoDataFrame to an OGR data source\n\n    A dictionary of supported OGR providers is available via:\n    >>> import fiona\n    >>> fiona.supported_drivers\n\n    Parameters\n    ----------\n    df : GeoDataFrame to be written\n    filename : string\n        File path or file handle to write to.\n    driver : string, default 'ESRI Shapefile'\n        The OGR format driver used to write the vector file.\n    schema : dict, default None\n        If specified, the schema dictionary is passed to Fiona to\n        better control how the file is written. If None, GeoPandas\n        will determine the schema based on each column's dtype\n\n    The *kwargs* are passed to fiona.open and can be used to write\n    to multi-layer data, store data within archives (zip files), etc.\n    \"\"\"\n    if schema is None:\n        schema = infer_schema(df)\n    filename = os.path.abspath(os.path.expanduser(filename))\n    with fiona_env():\n        with fiona.open(filename, 'w', driver=driver, crs=df.crs,\n                        schema=schema, **kwargs) as colxn:\n            colxn.writerecords(df.iterfeatures())\n\n\ndef infer_schema(df):\n    try:\n        from collections import OrderedDict\n    except ImportError:\n        from ordereddict import OrderedDict\n\n    def convert_type(column, in_type):\n        if in_type == object:\n            return 'str'\n        out_type = type(np.asscalar(np.zeros(1, in_type))).__name__\n        if out_type == 'long':\n            out_type = 'int'\n        if out_type == 'bool':\n            raise ValueError('column \"{}\" is boolean type, '.format(column) +\n                             'which is unsupported in file writing. '\n                             'Consider casting the column to int type.')\n        return out_type\n\n    properties = OrderedDict([\n        (col, convert_type(col, _type)) for col, _type in\n        zip(df.columns, df.dtypes) if col != df._geometry_column_name\n    ])\n\n    if df.empty:\n        raise ValueError(\"Cannot write empty DataFrame to file.\")\n\n    geom_type = _common_geom_type(df)\n    \n    if not geom_type:\n        raise ValueError(\"Geometry column cannot contain mutiple \"\n                         \"geometry types when writing to file.\")\n\n    schema = {'geometry': geom_type, 'properties': properties}\n\n    return schema\n\n\ndef _common_geom_type(df):\n    # Need to check geom_types before we write to file...\n    # Some (most?) providers expect a single geometry type:\n    # Point, LineString, or Polygon\n    geom_types = df.geometry.geom_type.unique()\n\n    from os.path import commonprefix\n    # use reversed geom types and commonprefix to find the common suffix,\n    # then reverse the result to get back to a geom type\n    geom_type = commonprefix([g[::-1] for g in geom_types if g])[::-1]\n    if not geom_type:\n        return None\n\n    if df.geometry.has_z.any():\n        geom_type = \"3D \" + geom_type\n\n    return geom_type\n", "path": "geopandas/io/file.py"}]}