We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ImageSequence.Iterator name is misleading
Hi Pillow developers,

I found this error message to be rather hilarious:

```
TypeError: 'Iterator' object is not an iterator
```

which was produced by this code:

``` python
from PIL import Image, ImageSequence

with Image.open('multipage.tiff', mode='r') as tif:
    i = ImageSequence.Iterator(tif)
    next(i)
```

It seems that `ImageSequence.Iterator` does not define an `__iter__()` method, which means that it is a sequence type but not an iterator type. In my opinion, this is misleading and I suggest that a proper `__iter__()` method should be added to the class definition.

Thanks.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `PIL/ImageSequence.py`
Content:
```
1 #
2 # The Python Imaging Library.
3 # $Id$
4 #
5 # sequence support classes
6 #
7 # history:
8 # 1997-02-20 fl     Created
9 #
10 # Copyright (c) 1997 by Secret Labs AB.
11 # Copyright (c) 1997 by Fredrik Lundh.
12 #
13 # See the README file for information on usage and redistribution.
14 #
15 
16 ##
17 
18 
19 class Iterator(object):
20     """
21     This class implements an iterator object that can be used to loop
22     over an image sequence.
23 
24     You can use the ``[]`` operator to access elements by index. This operator
25     will raise an :py:exc:`IndexError` if you try to access a nonexistent
26     frame.
27 
28     :param im: An image object.
29     """
30 
31     def __init__(self, im):
32         if not hasattr(im, "seek"):
33             raise AttributeError("im must have seek method")
34         self.im = im
35 
36     def __getitem__(self, ix):
37         try:
38             if ix:
39                 self.im.seek(ix)
40             return self.im
41         except EOFError:
42             raise IndexError  # end of sequence
43
```
--- 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/PIL/ImageSequence.py b/PIL/ImageSequence.py
--- a/PIL/ImageSequence.py
+++ b/PIL/ImageSequence.py
@@ -32,6 +32,7 @@
         if not hasattr(im, "seek"):
             raise AttributeError("im must have seek method")
         self.im = im
+        self.position = 0
 
     def __getitem__(self, ix):
         try:
@@ -40,3 +41,17 @@
             return self.im
         except EOFError:
             raise IndexError  # end of sequence
+
+    def __iter__(self):
+        return self
+
+    def __next__(self):
+        try:
+            self.im.seek(self.position)
+            self.position += 1
+            return self.im
+        except EOFError:
+            raise StopIteration
+
+    def next(self):
+        return self.__next__()

{"golden_diff": "diff --git a/PIL/ImageSequence.py b/PIL/ImageSequence.py\n--- a/PIL/ImageSequence.py\n+++ b/PIL/ImageSequence.py\n@@ -32,6 +32,7 @@\n         if not hasattr(im, \"seek\"):\n             raise AttributeError(\"im must have seek method\")\n         self.im = im\n+        self.position = 0\n \n     def __getitem__(self, ix):\n         try:\n@@ -40,3 +41,17 @@\n             return self.im\n         except EOFError:\n             raise IndexError  # end of sequence\n+\n+    def __iter__(self):\n+        return self\n+\n+    def __next__(self):\n+        try:\n+            self.im.seek(self.position)\n+            self.position += 1\n+            return self.im\n+        except EOFError:\n+            raise StopIteration\n+\n+    def next(self):\n+        return self.__next__()\n", "issue": "ImageSequence.Iterator name is misleading\nHi Pillow developers,\n\nI found this error message to be rather hilarious:\n\n```\nTypeError: 'Iterator' object is not an iterator\n```\n\nwhich was produced by this code:\n\n``` python\nfrom PIL import Image, ImageSequence\n\nwith Image.open('multipage.tiff', mode='r') as tif:\n    i = ImageSequence.Iterator(tif)\n    next(i)\n```\n\nIt seems that `ImageSequence.Iterator` does not define an `__iter__()` method, which means that it is a sequence type but not an iterator type. In my opinion, this is misleading and I suggest that a proper `__iter__()` method should be added to the class definition.\n\nThanks.\n\n", "before_files": [{"content": "#\n# The Python Imaging Library.\n# $Id$\n#\n# sequence support classes\n#\n# history:\n# 1997-02-20 fl     Created\n#\n# Copyright (c) 1997 by Secret Labs AB.\n# Copyright (c) 1997 by Fredrik Lundh.\n#\n# See the README file for information on usage and redistribution.\n#\n\n##\n\n\nclass Iterator(object):\n    \"\"\"\n    This class implements an iterator object that can be used to loop\n    over an image sequence.\n\n    You can use the ``[]`` operator to access elements by index. This operator\n    will raise an :py:exc:`IndexError` if you try to access a nonexistent\n    frame.\n\n    :param im: An image object.\n    \"\"\"\n\n    def __init__(self, im):\n        if not hasattr(im, \"seek\"):\n            raise AttributeError(\"im must have seek method\")\n        self.im = im\n\n    def __getitem__(self, ix):\n        try:\n            if ix:\n                self.im.seek(ix)\n            return self.im\n        except EOFError:\n            raise IndexError  # end of sequence\n", "path": "PIL/ImageSequence.py"}], "after_files": [{"content": "#\n# The Python Imaging Library.\n# $Id$\n#\n# sequence support classes\n#\n# history:\n# 1997-02-20 fl     Created\n#\n# Copyright (c) 1997 by Secret Labs AB.\n# Copyright (c) 1997 by Fredrik Lundh.\n#\n# See the README file for information on usage and redistribution.\n#\n\n##\n\n\nclass Iterator(object):\n    \"\"\"\n    This class implements an iterator object that can be used to loop\n    over an image sequence.\n\n    You can use the ``[]`` operator to access elements by index. This operator\n    will raise an :py:exc:`IndexError` if you try to access a nonexistent\n    frame.\n\n    :param im: An image object.\n    \"\"\"\n\n    def __init__(self, im):\n        if not hasattr(im, \"seek\"):\n            raise AttributeError(\"im must have seek method\")\n        self.im = im\n        self.position = 0\n\n    def __getitem__(self, ix):\n        try:\n            if ix:\n                self.im.seek(ix)\n            return self.im\n        except EOFError:\n            raise IndexError  # end of sequence\n\n    def __iter__(self):\n        return self\n\n    def __next__(self):\n        try:\n            self.im.seek(self.position)\n            self.position += 1\n            return self.im\n        except EOFError:\n            raise StopIteration\n\n    def next(self):\n        return self.__next__()\n", "path": "PIL/ImageSequence.py"}]}