We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Single int indexes param in sample method
According to docs the `indexes` param in the `sample` method can be a "list of ints or a single int".

However passing a single int raises this exception: `IndexError: too many indices for array`.


--- 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/sample.py`
Content:
```
1 # Workaround for issue #378. A pure Python generator.
2 
3 def sample_gen(dataset, xy, indexes=None):
4     index = dataset.index
5     read = dataset.read
6     for x, y in xy:
7         r, c = index(x, y)
8         window = ((r, r+1), (c, c+1))
9         data = read(indexes, window=window, masked=False, boundless=True)
10         yield data[:,0,0]
11
```
--- 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/sample.py b/rasterio/sample.py
--- a/rasterio/sample.py
+++ b/rasterio/sample.py
@@ -3,6 +3,10 @@
 def sample_gen(dataset, xy, indexes=None):
     index = dataset.index
     read = dataset.read
+
+    if isinstance(indexes, int):
+        indexes = [indexes]
+
     for x, y in xy:
         r, c = index(x, y)
         window = ((r, r+1), (c, c+1))

{"golden_diff": "diff --git a/rasterio/sample.py b/rasterio/sample.py\n--- a/rasterio/sample.py\n+++ b/rasterio/sample.py\n@@ -3,6 +3,10 @@\n def sample_gen(dataset, xy, indexes=None):\n     index = dataset.index\n     read = dataset.read\n+\n+    if isinstance(indexes, int):\n+        indexes = [indexes]\n+\n     for x, y in xy:\n         r, c = index(x, y)\n         window = ((r, r+1), (c, c+1))\n", "issue": "Single int indexes param in sample method\nAccording to docs the `indexes` param in the `sample` method can be a \"list of ints or a single int\".\n\nHowever passing a single int raises this exception: `IndexError: too many indices for array`.\n\n", "before_files": [{"content": "# Workaround for issue #378. A pure Python generator.\n\ndef sample_gen(dataset, xy, indexes=None):\n    index = dataset.index\n    read = dataset.read\n    for x, y in xy:\n        r, c = index(x, y)\n        window = ((r, r+1), (c, c+1))\n        data = read(indexes, window=window, masked=False, boundless=True)\n        yield data[:,0,0]\n", "path": "rasterio/sample.py"}], "after_files": [{"content": "# Workaround for issue #378. A pure Python generator.\n\ndef sample_gen(dataset, xy, indexes=None):\n    index = dataset.index\n    read = dataset.read\n\n    if isinstance(indexes, int):\n        indexes = [indexes]\n\n    for x, y in xy:\n        r, c = index(x, y)\n        window = ((r, r+1), (c, c+1))\n        data = read(indexes, window=window, masked=False, boundless=True)\n        yield data[:,0,0]\n", "path": "rasterio/sample.py"}]}