Fix for internal running of tests.

PiperOrigin-RevId: 444297087
diff --git a/python/descriptor_pool.c b/python/descriptor_pool.c
index 5a61b4e..b8ca06d 100644
--- a/python/descriptor_pool.c
+++ b/python/descriptor_pool.c
@@ -572,11 +572,18 @@
   size_t n;
   const upb_FieldDef** ext = upb_DefPool_GetAllExtensions(self->symtab, m, &n);
   PyObject* ret = PyList_New(n);
+  if (!ret) goto done;
   for (size_t i = 0; i < n; i++) {
     PyObject* field = PyUpb_FieldDescriptor_Get(ext[i]);
-    if (!field) return NULL;
+    if (!field) {
+      Py_DECREF(ret);
+      ret = NULL;
+      goto done;
+    }
     PyList_SetItem(ret, i, field);
   }
+done:
+  free(ext);
   return ret;
 }
 
diff --git a/python/pb_unit_tests/descriptor_pool_test_wrapper.py b/python/pb_unit_tests/descriptor_pool_test_wrapper.py
index 69b573c..bb15306 100644
--- a/python/pb_unit_tests/descriptor_pool_test_wrapper.py
+++ b/python/pb_unit_tests/descriptor_pool_test_wrapper.py
@@ -23,13 +23,8 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-from google.protobuf.internal import descriptor_pool_test
 import unittest
-import copy
-
-# begin:google_only
-# from google3.testing.pybase import googletest
-# end:google_only
+from google.protobuf.internal import descriptor_pool_test
 
 # This is testing that certain methods unconditionally throw TypeError.
 # In the new extension we simply don't define them at all.
@@ -43,6 +38,8 @@
 # end:github_only
 
 # begin:google_only
+# descriptor_pool_test.CreateDescriptorPoolTest.testComplexNestingWithProtoFileParser.__unittest_expecting_failure__ = True
+# from absl import app
 # if __name__ == '__main__':
-#   googletest.main()
+#   app.run(lambda argv: unittest.main(module=descriptor_pool_test, verbosity=2))
 # end:google_only