Repository: python-pillow/Pillow

Problem statement:
type list doesn't define __round__ method
<!--
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?

I saved .apng file

### What did you expect to happen?

Running with no exception

### What actually happened?

I got "type list doesn't define \_\_round\_\_ method" error in function "_write_multiple_frames"
https://github.com/python-pillow/Pillow/blob/83c05aaf8daa930086257eb38b254f06808d13e5/src/PIL/PngImagePlugin.py#L1060

https://github.com/python-pillow/Pillow/blob/83c05aaf8daa930086257eb38b254f06808d13e5/src/PIL/PngImagePlugin.py#L1152

### What are your OS, Python and Pillow versions?

* OS: MacOS
* Python: 3.8.2
* Pillow: 8.3.1

<!--
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.
-->



Hints:

Patch:
diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py
--- a/src/PIL/PngImagePlugin.py
+++ b/src/PIL/PngImagePlugin.py
@@ -1117,12 +1117,12 @@ def _write_multiple_frames(im, fp, chunk, rawmode):
                     and prev_disposal == encoderinfo.get("disposal")
                     and prev_blend == encoderinfo.get("blend")
                 ):
-                    duration = encoderinfo.get("duration", 0)
-                    if duration:
+                    frame_duration = encoderinfo.get("duration", 0)
+                    if frame_duration:
                         if "duration" in previous["encoderinfo"]:
-                            previous["encoderinfo"]["duration"] += duration
+                            previous["encoderinfo"]["duration"] += frame_duration
                         else:
-                            previous["encoderinfo"]["duration"] = duration
+                            previous["encoderinfo"]["duration"] = frame_duration
                     continue
             else:
                 bbox = None


Test patch:
diff --git a/Tests/test_file_apng.py b/Tests/test_file_apng.py
--- a/Tests/test_file_apng.py
+++ b/Tests/test_file_apng.py
@@ -433,7 +433,9 @@ def test_apng_save_duration_loop(tmp_path):
 
     # test removal of duplicated frames
     frame = Image.new("RGBA", (128, 64), (255, 0, 0, 255))
-    frame.save(test_file, save_all=True, append_images=[frame], duration=[500, 250])
+    frame.save(
+        test_file, save_all=True, append_images=[frame, frame], duration=[500, 100, 150]
+    )
     with Image.open(test_file) as im:
         im.load()
         assert im.n_frames == 1