bpo-37417: Fix error handling in bytearray.extend. (GH-14407)

(cherry picked from commit 2a7d596f27b2342caf168a03c95ebf3b56e5dbbd)

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index c684db7..1bb19a9 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -1698,6 +1698,10 @@
     }
     Py_DECREF(bytearray_obj);
 
+    if (PyErr_Occurred()) {
+        return NULL;
+    }
+
     Py_RETURN_NONE;
 }