Repository: python-pillow/Pillow

Issue:
getpixel() should work with list of length 2
<!--
Thank you for reporting an issue.

Follow these guidelines to ensure your issue is handled properly.

If you have a ...

1.  General question: consider asking the question on Stack Overflow
    with the python-imaging-library tag:

    * https://stackoverflow.com/questions/tagged/python-imaging-library

    Do not ask a question in both places.

    If you think you have found a bug or have an unexplained exception
    then file a bug report here.

2.  Bug report: include a self-contained, copy-pastable example that
    generates the issue if possible. Be concise with code posted.
    Guidelines on how to provide a good bug report:

    * https://stackoverflow.com/help/mcve

    Bug reports which follow these guidelines are easier to diagnose,
    and are often handled much more quickly.

3.  Feature request: do a quick search of existing issues
    to make sure this has not been asked before.

We know asking good questions takes effort, and we appreciate your time.
Thank you.
-->

### What did you do?
`img.getpixel([473, 653])`

### What did you expect to happen?
the pixel at that position is returned

### What actually happened?
An unexpected error message: `TypeError: argument must be sequence of length 2`

But the argument is a **sequence** of length 2

### What are your OS, Python and Pillow versions?

* OS: Ubuntu 18.04
* Python: 3.9
* Pillow: '9.4.0'

<!--
Please include **code** that reproduces the issue and whenever possible, an **image** that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.

The best reproductions are self-contained scripts with minimal dependencies. If you are using a framework such as Plone, Django, or Buildout, try to replicate the issue just using Pillow.
-->

```python
img = Image.open('test.png')
img.getpixel([473, 653])
```



Discussion:
It's expecting a tuple not a list:

https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.getpixel

https://github.com/python-pillow/Pillow/blob/643a52a2eb7bda9e809e4806ad14806b4f9c6fe2/src/_imaging.c#L1149-L1151
https://github.com/python-pillow/Pillow/blob/643a52a2eb7bda9e809e4806ad14806b4f9c6fe2/src/_imaging.c#L1183-L1185
> It's expecting a tuple not a list:

But the question is why it can't be a list? "argument must be sequence of length 2", list is also a sequence. So behavior or message should be changed.
Exactly! Thanks, @homm 

Of course, I would much prefer it it could take any sequence of 2 integers, so we could pass lists, numpy arrays, etc, as long as they have 2 integers. 

Would probably have been easier if it took 2 integer arguments, but I suppose there's no changing the interface now
I think that could be done actually. Something like this:

```python
def getPixel(self, x, y=None):
    if y is None:
        xy = tuple(x)
    else:
        xy = (x, y)
```

Resolving patch:
diff --git a/src/PIL/Image.py b/src/PIL/Image.py
--- a/src/PIL/Image.py
+++ b/src/PIL/Image.py
@@ -1565,7 +1565,7 @@ def getpixel(self, xy):
         self.load()
         if self.pyaccess:
             return self.pyaccess.getpixel(xy)
-        return self.im.getpixel(xy)
+        return self.im.getpixel(tuple(xy))
 
     def getprojection(self):
         """


Test patch:
diff --git a/Tests/test_image_access.py b/Tests/test_image_access.py
--- a/Tests/test_image_access.py
+++ b/Tests/test_image_access.py
@@ -213,6 +213,10 @@ def check(self, mode, expected_color=None):
     def test_basic(self, mode):
         self.check(mode)
 
+    def test_list(self):
+        im = hopper()
+        assert im.getpixel([0, 0]) == (20, 20, 70)
+
     @pytest.mark.parametrize("mode", ("I;16", "I;16B"))
     @pytest.mark.parametrize(
         "expected_color", (2**15 - 1, 2**15, 2**15 + 1, 2**16 - 1)