Remove RegisterExtension in message class

PiperOrigin-RevId: 539568063
diff --git a/python/extension_dict.c b/python/extension_dict.c
index aa714a3..48bb2de 100644
--- a/python/extension_dict.c
+++ b/python/extension_dict.c
@@ -53,6 +53,10 @@
                                                          PyObject* key) {
   PyUpb_ExtensionDict* self = (PyUpb_ExtensionDict*)_self;
   const char* name = PyUpb_GetStrData(key);
+  if (!name) {
+    PyErr_Format(PyExc_TypeError, "_FindExtensionByName expect a str");
+    return NULL;
+  }
   const upb_MessageDef* m = PyUpb_Message_GetMsgdef(self->msg);
   const upb_FileDef* file = upb_MessageDef_File(m);
   const upb_DefPool* symtab = upb_FileDef_Pool(file);
@@ -73,6 +77,7 @@
   const upb_DefPool* symtab = upb_FileDef_Pool(file);
   const upb_ExtensionRegistry* reg = upb_DefPool_ExtensionRegistry(symtab);
   int64_t number = PyLong_AsLong(arg);
+  if (number == -1 && PyErr_Occurred()) return NULL;
   const upb_MiniTableExtension* ext =
       (upb_MiniTableExtension*)upb_ExtensionRegistry_Lookup(reg, l, number);
   if (ext) {
diff --git a/python/message.c b/python/message.c
index 0e42a98..a01ce16 100644
--- a/python/message.c
+++ b/python/message.c
@@ -1677,10 +1677,6 @@
      "Merges a serialized message into the current message."},
     {"ParseFromString", PyUpb_Message_ParseFromString, METH_O,
      "Parses a serialized message into the current message."},
-    // TODO(https://github.com/protocolbuffers/upb/issues/459)
-    //{ "RegisterExtension", (PyCFunction)RegisterExtension, METH_O |
-    // METH_CLASS,
-    //  "Registers an extension with the current message." },
     {"SerializePartialToString",
      (PyCFunction)PyUpb_Message_SerializePartialToString,
      METH_VARARGS | METH_KEYWORDS,