diff --git a/bazel/workspace_deps.bzl b/bazel/workspace_deps.bzl index cfe532efb1..2d004d0c2a 100644 --- a/bazel/workspace_deps.bzl +++ b/bazel/workspace_deps.bzl @@ -23,8 +23,8 @@ def upb_deps(): _github_archive, name = "com_google_protobuf", repo = "https://github.com/protocolbuffers/protobuf", - commit = "e202f31b78a9189fbebe25c3cae8e7a1733d6316", - sha256 = "fc2eb31c2fef530c305dad5c4b38b3afcd90dd3955368c1acab8cfe38b7ecb03", + commit = "65e047d098bfdbed787b39d8facc0b74cf3cff73", + sha256 = "807c22ebfb865aa35c17bae77b8f8ecc19c9509c122dbc36f6262cb3c83f1f3c", patches = ["@upb//bazel:protobuf.patch"], ) diff --git a/python/message.c b/python/message.c index cc5bd77dfc..0e42a9884c 100644 --- a/python/message.c +++ b/python/message.c @@ -1601,6 +1601,19 @@ static PyObject* PyUpb_Message_WhichOneof(PyObject* _self, PyObject* name) { return PyUnicode_FromString(upb_FieldDef_Name(f)); } +PyObject* DeepCopy(PyObject* _self, PyObject* arg) { + PyUpb_Message* self = (void*)_self; + + PyObject* arena = PyUpb_Arena_New(); + upb_Message* clone = + upb_Message_DeepClone(self->ptr.msg, upb_MessageDef_MiniTable(self->def), + PyUpb_Arena_Get(arena)); + PyObject* ret = PyUpb_Message_Get(clone, self->def, arena); + Py_DECREF(arena); + + return ret; +} + void PyUpb_Message_ClearExtensionDict(PyObject* _self) { PyUpb_Message* self = (void*)_self; assert(self->ext_dict); @@ -1630,9 +1643,9 @@ static PyGetSetDef PyUpb_Message_Getters[] = { {NULL}}; static PyMethodDef PyUpb_Message_Methods[] = { + {"__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS, + "Makes a deep copy of the class."}, // TODO(https://github.com/protocolbuffers/upb/issues/459) - //{ "__deepcopy__", (PyCFunction)DeepCopy, METH_VARARGS, - // "Makes a deep copy of the class." }, //{ "__unicode__", (PyCFunction)ToUnicode, METH_NOARGS, // "Outputs a unicode representation of the message." }, {"ByteSize", (PyCFunction)PyUpb_Message_ByteSize, METH_NOARGS,