We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
rio stack output empty
`rio stack`ing one or more rasters without an explicit band index results in a raster with all nulls

```
$ rio info --tell-me-more tests/data/RGB.byte.tif | jq .stats[0].max
255
$ rio stack tests/data/RGB.byte.tif /tmp/test.tif && \
  rio info --tell-me-more /tmp/test.tif | jq .stats[0].max
null
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `rasterio/rio/stack.py`
Content:
```
1 """Commands for operating on bands of datasets."""
2 import logging
3 
4 import click
5 from cligj import files_inout_arg, format_opt
6 
7 from .helpers import resolve_inout
8 from . import options
9 import rasterio
10 from rasterio.five import zip_longest
11 
12 
13 # Stack command.
14 @click.command(short_help="Stack a number of bands into a multiband dataset.")
15 @files_inout_arg
16 @options.output_opt
17 @format_opt
18 @options.bidx_mult_opt
19 @options.rgb_opt
20 @options.force_overwrite_opt
21 @options.creation_options
22 @click.pass_context
23 def stack(ctx, files, output, driver, bidx, photometric, force_overwrite,
24           creation_options):
25     """Stack a number of bands from one or more input files into a
26     multiband dataset.
27 
28     Input datasets must be of a kind: same data type, dimensions, etc. The
29     output is cloned from the first input.
30 
31     By default, rio-stack will take all bands from each input and write them
32     in same order to the output. Optionally, bands for each input may be
33     specified using a simple syntax:
34 
35       --bidx N takes the Nth band from the input (first band is 1).
36 
37       --bidx M,N,0 takes bands M, N, and O.
38 
39       --bidx M..O takes bands M-O, inclusive.
40 
41       --bidx ..N takes all bands up to and including N.
42 
43       --bidx N.. takes all bands from N to the end.
44 
45     Examples, using the Rasterio testing dataset, which produce a copy.
46 
47       rio stack RGB.byte.tif -o stacked.tif
48 
49       rio stack RGB.byte.tif --bidx 1,2,3 -o stacked.tif
50 
51       rio stack RGB.byte.tif --bidx 1..3 -o stacked.tif
52 
53       rio stack RGB.byte.tif --bidx ..2 RGB.byte.tif --bidx 3.. -o stacked.tif
54 
55     """
56 
57     verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 2
58     logger = logging.getLogger('rio')
59     try:
60         with rasterio.drivers(CPL_DEBUG=verbosity>2):
61             output, files = resolve_inout(files=files, output=output,
62                 force_overwrite=force_overwrite)
63             output_count = 0
64             indexes = []
65             for path, item in zip_longest(files, bidx, fillvalue=None):
66                 with rasterio.open(path) as src:
67                     src_indexes = src.indexes
68                 if item is None:
69                     indexes.append(src_indexes)
70                     output_count += len(src_indexes)
71                 elif '..' in item:
72                     start, stop = map(
73                         lambda x: int(x) if x else None, item.split('..'))
74                     if start is None:
75                         start = 1
76                     indexes.append(src_indexes[slice(start-1, stop)])
77                     output_count += len(src_indexes[slice(start-1, stop)])
78                 else:
79                     parts = list(map(int, item.split(',')))
80                     if len(parts) == 1:
81                         indexes.append(parts[0])
82                         output_count += 1
83                     else:
84                         parts = list(parts)
85                         indexes.append(parts)
86                         output_count += len(parts)
87 
88             with rasterio.open(files[0]) as first:
89                 kwargs = first.meta
90                 kwargs.update(**creation_options)
91                 kwargs['transform'] = kwargs.pop('affine')
92 
93             kwargs.update(
94                 driver=driver,
95                 count=output_count)
96 
97             if photometric:
98                 kwargs['photometric'] = photometric
99 
100             with rasterio.open(output, 'w', **kwargs) as dst:
101                 dst_idx = 1
102                 for path, index in zip(files, indexes):
103                     with rasterio.open(path) as src:
104                         if isinstance(index, int):
105                             data = src.read(index)
106                             dst.write(data, dst_idx)
107                             dst_idx += 1
108                         elif isinstance(index, list):
109                             data = src.read(index)
110                             dst.write(data, range(dst_idx, dst_idx+len(index)))
111                             dst_idx += len(index)
112 
113     except Exception:
114         logger.exception("Exception caught during processing")
115         raise click.Abort()
116
```
--- 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()

```

diff --git a/rasterio/rio/stack.py b/rasterio/rio/stack.py
--- a/rasterio/rio/stack.py
+++ b/rasterio/rio/stack.py
@@ -1,4 +1,5 @@
 """Commands for operating on bands of datasets."""
+import collections
 import logging
 
 import click
@@ -105,7 +106,7 @@
                             data = src.read(index)
                             dst.write(data, dst_idx)
                             dst_idx += 1
-                        elif isinstance(index, list):
+                        elif isinstance(index, collections.Iterable):
                             data = src.read(index)
                             dst.write(data, range(dst_idx, dst_idx+len(index)))
                             dst_idx += len(index)

{"golden_diff": "diff --git a/rasterio/rio/stack.py b/rasterio/rio/stack.py\n--- a/rasterio/rio/stack.py\n+++ b/rasterio/rio/stack.py\n@@ -1,4 +1,5 @@\n \"\"\"Commands for operating on bands of datasets.\"\"\"\n+import collections\n import logging\n \n import click\n@@ -105,7 +106,7 @@\n                             data = src.read(index)\n                             dst.write(data, dst_idx)\n                             dst_idx += 1\n-                        elif isinstance(index, list):\n+                        elif isinstance(index, collections.Iterable):\n                             data = src.read(index)\n                             dst.write(data, range(dst_idx, dst_idx+len(index)))\n                             dst_idx += len(index)\n", "issue": "rio stack output empty\n`rio stack`ing one or more rasters without an explicit band index results in a raster with all nulls\n\n```\n$ rio info --tell-me-more tests/data/RGB.byte.tif | jq .stats[0].max\n255\n$ rio stack tests/data/RGB.byte.tif /tmp/test.tif && \\\n  rio info --tell-me-more /tmp/test.tif | jq .stats[0].max\nnull\n```\n\n", "before_files": [{"content": "\"\"\"Commands for operating on bands of datasets.\"\"\"\nimport logging\n\nimport click\nfrom cligj import files_inout_arg, format_opt\n\nfrom .helpers import resolve_inout\nfrom . import options\nimport rasterio\nfrom rasterio.five import zip_longest\n\n\n# Stack command.\n@click.command(short_help=\"Stack a number of bands into a multiband dataset.\")\n@files_inout_arg\n@options.output_opt\n@format_opt\n@options.bidx_mult_opt\n@options.rgb_opt\n@options.force_overwrite_opt\n@options.creation_options\n@click.pass_context\ndef stack(ctx, files, output, driver, bidx, photometric, force_overwrite,\n          creation_options):\n    \"\"\"Stack a number of bands from one or more input files into a\n    multiband dataset.\n\n    Input datasets must be of a kind: same data type, dimensions, etc. The\n    output is cloned from the first input.\n\n    By default, rio-stack will take all bands from each input and write them\n    in same order to the output. Optionally, bands for each input may be\n    specified using a simple syntax:\n\n      --bidx N takes the Nth band from the input (first band is 1).\n\n      --bidx M,N,0 takes bands M, N, and O.\n\n      --bidx M..O takes bands M-O, inclusive.\n\n      --bidx ..N takes all bands up to and including N.\n\n      --bidx N.. takes all bands from N to the end.\n\n    Examples, using the Rasterio testing dataset, which produce a copy.\n\n      rio stack RGB.byte.tif -o stacked.tif\n\n      rio stack RGB.byte.tif --bidx 1,2,3 -o stacked.tif\n\n      rio stack RGB.byte.tif --bidx 1..3 -o stacked.tif\n\n      rio stack RGB.byte.tif --bidx ..2 RGB.byte.tif --bidx 3.. -o stacked.tif\n\n    \"\"\"\n\n    verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 2\n    logger = logging.getLogger('rio')\n    try:\n        with rasterio.drivers(CPL_DEBUG=verbosity>2):\n            output, files = resolve_inout(files=files, output=output,\n                force_overwrite=force_overwrite)\n            output_count = 0\n            indexes = []\n            for path, item in zip_longest(files, bidx, fillvalue=None):\n                with rasterio.open(path) as src:\n                    src_indexes = src.indexes\n                if item is None:\n                    indexes.append(src_indexes)\n                    output_count += len(src_indexes)\n                elif '..' in item:\n                    start, stop = map(\n                        lambda x: int(x) if x else None, item.split('..'))\n                    if start is None:\n                        start = 1\n                    indexes.append(src_indexes[slice(start-1, stop)])\n                    output_count += len(src_indexes[slice(start-1, stop)])\n                else:\n                    parts = list(map(int, item.split(',')))\n                    if len(parts) == 1:\n                        indexes.append(parts[0])\n                        output_count += 1\n                    else:\n                        parts = list(parts)\n                        indexes.append(parts)\n                        output_count += len(parts)\n\n            with rasterio.open(files[0]) as first:\n                kwargs = first.meta\n                kwargs.update(**creation_options)\n                kwargs['transform'] = kwargs.pop('affine')\n\n            kwargs.update(\n                driver=driver,\n                count=output_count)\n\n            if photometric:\n                kwargs['photometric'] = photometric\n\n            with rasterio.open(output, 'w', **kwargs) as dst:\n                dst_idx = 1\n                for path, index in zip(files, indexes):\n                    with rasterio.open(path) as src:\n                        if isinstance(index, int):\n                            data = src.read(index)\n                            dst.write(data, dst_idx)\n                            dst_idx += 1\n                        elif isinstance(index, list):\n                            data = src.read(index)\n                            dst.write(data, range(dst_idx, dst_idx+len(index)))\n                            dst_idx += len(index)\n\n    except Exception:\n        logger.exception(\"Exception caught during processing\")\n        raise click.Abort()\n", "path": "rasterio/rio/stack.py"}], "after_files": [{"content": "\"\"\"Commands for operating on bands of datasets.\"\"\"\nimport collections\nimport logging\n\nimport click\nfrom cligj import files_inout_arg, format_opt\n\nfrom .helpers import resolve_inout\nfrom . import options\nimport rasterio\nfrom rasterio.five import zip_longest\n\n\n# Stack command.\n@click.command(short_help=\"Stack a number of bands into a multiband dataset.\")\n@files_inout_arg\n@options.output_opt\n@format_opt\n@options.bidx_mult_opt\n@options.rgb_opt\n@options.force_overwrite_opt\n@options.creation_options\n@click.pass_context\ndef stack(ctx, files, output, driver, bidx, photometric, force_overwrite,\n          creation_options):\n    \"\"\"Stack a number of bands from one or more input files into a\n    multiband dataset.\n\n    Input datasets must be of a kind: same data type, dimensions, etc. The\n    output is cloned from the first input.\n\n    By default, rio-stack will take all bands from each input and write them\n    in same order to the output. Optionally, bands for each input may be\n    specified using a simple syntax:\n\n      --bidx N takes the Nth band from the input (first band is 1).\n\n      --bidx M,N,0 takes bands M, N, and O.\n\n      --bidx M..O takes bands M-O, inclusive.\n\n      --bidx ..N takes all bands up to and including N.\n\n      --bidx N.. takes all bands from N to the end.\n\n    Examples, using the Rasterio testing dataset, which produce a copy.\n\n      rio stack RGB.byte.tif -o stacked.tif\n\n      rio stack RGB.byte.tif --bidx 1,2,3 -o stacked.tif\n\n      rio stack RGB.byte.tif --bidx 1..3 -o stacked.tif\n\n      rio stack RGB.byte.tif --bidx ..2 RGB.byte.tif --bidx 3.. -o stacked.tif\n\n    \"\"\"\n\n    verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 2\n    logger = logging.getLogger('rio')\n    try:\n        with rasterio.drivers(CPL_DEBUG=verbosity>2):\n            output, files = resolve_inout(files=files, output=output,\n                force_overwrite=force_overwrite)\n            output_count = 0\n            indexes = []\n            for path, item in zip_longest(files, bidx, fillvalue=None):\n                with rasterio.open(path) as src:\n                    src_indexes = src.indexes\n                if item is None:\n                    indexes.append(src_indexes)\n                    output_count += len(src_indexes)\n                elif '..' in item:\n                    start, stop = map(\n                        lambda x: int(x) if x else None, item.split('..'))\n                    if start is None:\n                        start = 1\n                    indexes.append(src_indexes[slice(start-1, stop)])\n                    output_count += len(src_indexes[slice(start-1, stop)])\n                else:\n                    parts = list(map(int, item.split(',')))\n                    if len(parts) == 1:\n                        indexes.append(parts[0])\n                        output_count += 1\n                    else:\n                        parts = list(parts)\n                        indexes.append(parts)\n                        output_count += len(parts)\n\n            with rasterio.open(files[0]) as first:\n                kwargs = first.meta\n                kwargs.update(**creation_options)\n                kwargs['transform'] = kwargs.pop('affine')\n\n            kwargs.update(\n                driver=driver,\n                count=output_count)\n\n            if photometric:\n                kwargs['photometric'] = photometric\n\n            with rasterio.open(output, 'w', **kwargs) as dst:\n                dst_idx = 1\n                for path, index in zip(files, indexes):\n                    with rasterio.open(path) as src:\n                        if isinstance(index, int):\n                            data = src.read(index)\n                            dst.write(data, dst_idx)\n                            dst_idx += 1\n                        elif isinstance(index, collections.Iterable):\n                            data = src.read(index)\n                            dst.write(data, range(dst_idx, dst_idx+len(index)))\n                            dst_idx += len(index)\n\n    except Exception:\n        logger.exception(\"Exception caught during processing\")\n        raise click.Abort()\n", "path": "rasterio/rio/stack.py"}]}