Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-04-20 06:01:14 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-04-21 12:09:06 +0300
commitd3e2bc9fcb09ac5fccdd3a931f1cc10a1d22950c (patch)
tree78783d083a5d5d008e917fb8af73a28edf635db7
parentf0862773b4ddfffd657690d6407e8bafbeed8838 (diff)
Fix crash passing no arguments to Context.temp_override
-rw-r--r--source/blender/python/intern/bpy_rna_context.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/python/intern/bpy_rna_context.c b/source/blender/python/intern/bpy_rna_context.c
index 085a8323cc1..811552ce938 100644
--- a/source/blender/python/intern/bpy_rna_context.c
+++ b/source/blender/python/intern/bpy_rna_context.c
@@ -208,10 +208,17 @@ static PyObject *bpy_context_temp_override(PyObject *self, PyObject *args, PyObj
if (context_ptr == NULL) {
return NULL;
}
- /* Needed because the keywords copied into `kwds_parse` could contain anything.
- * As the types of keys aren't checked. */
- if (!PyArg_ValidateKeywordArguments(kwds)) {
- return NULL;
+
+ if (kwds == NULL) {
+ /* While this is effectively NOP, support having no keywords as it's more involved
+ * to return an alternative (dummy) context manager. */
+ }
+ else {
+ /* Needed because the keywords copied into `kwds_parse` could contain anything.
+ * As the types of keys aren't checked. */
+ if (!PyArg_ValidateKeywordArguments(kwds)) {
+ return NULL;
+ }
}
struct {
@@ -235,7 +242,7 @@ static PyObject *bpy_context_temp_override(PyObject *self, PyObject *args, PyObj
0,
};
/* Parse known keywords, the remaining keywords are set using #CTX_py_state_push. */
- kwds = PyDict_Copy(kwds);
+ kwds = kwds ? PyDict_Copy(kwds) : PyDict_New();
{
PyObject *kwds_parse = bpy_context_temp_override_extract_known_args(_keywords, kwds);
const int parse_result = _PyArg_ParseTupleAndKeywordsFast(args,