forked from easybuilders/easybuild-easyconfigs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch upb CopyFrom error in protobuf-python 4.24.0
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
easybuild/easyconfigs/p/protobuf-python/protobuf-python-4.24.0_fix-upb-copyfrom.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
From 57636ce03ac1e2aab3a362a61a6664981e21cda5 Mon Sep 17 00:00:00 2001 | ||
From: Jie Luo <[email protected]> | ||
Date: Thu, 24 Aug 2023 14:27:41 -0700 | ||
Subject: [PATCH] upb CopyFrom the default empty message should just clear | ||
instead of deep copy from memory | ||
|
||
fix https://github.com/protocolbuffers/protobuf/issues/13485 | ||
|
||
PiperOrigin-RevId: 559870202 | ||
--- | ||
python/message.c | 15 +++++++++------ | ||
1 file changed, 9 insertions(+), 6 deletions(-) | ||
|
||
diff --git a/python/message.c b/python/message.c | ||
index afdd4311a..e61eebb23 100644 | ||
--- a/python/message.c | ||
+++ b/python/message.c | ||
@@ -1237,12 +1237,15 @@ static PyObject* PyUpb_Message_CopyFrom(PyObject* _self, PyObject* arg) { | ||
PyUpb_Message* other = (void*)arg; | ||
PyUpb_Message_EnsureReified(self); | ||
|
||
- PyObject* tmp = PyUpb_Message_Clear(self); | ||
- Py_DECREF(tmp); | ||
- | ||
- upb_Message_DeepCopy(self->ptr.msg, other->ptr.msg, | ||
- upb_MessageDef_MiniTable(other->def), | ||
- PyUpb_Arena_Get(self->arena)); | ||
+ const upb_Message* other_msg = PyUpb_Message_GetIfReified((PyObject*)other); | ||
+ if (other_msg) { | ||
+ upb_Message_DeepCopy(self->ptr.msg, other_msg, | ||
+ upb_MessageDef_MiniTable(other->def), | ||
+ PyUpb_Arena_Get(self->arena)); | ||
+ } else { | ||
+ PyObject* tmp = PyUpb_Message_Clear(self); | ||
+ Py_DECREF(tmp); | ||
+ } | ||
PyUpb_Message_SyncSubobjs(self); | ||
|
||
Py_RETURN_NONE; |