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:
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c54
-rw-r--r--source/blender/python/generic/py_capi_utils.c6
-rw-r--r--source/blender/python/generic/py_capi_utils.h2
-rw-r--r--source/blender/python/gpu/gpu_py_shader.c19
-rw-r--r--source/blender/python/intern/bpy_app.c5
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c2
-rw-r--r--source/blender/python/intern/bpy_interface.c20
-rw-r--r--source/blender/python/intern/bpy_interface_atexit.c2
-rw-r--r--source/blender/python/intern/bpy_library_load.c32
-rw-r--r--source/blender/python/intern/bpy_rna.c16
10 files changed, 84 insertions, 74 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 38122c45ef1..e9499818f64 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -293,7 +293,7 @@ static int bpy_bmesh_select_mode_set(BPy_BMesh *self, PyObject *value)
return -1;
}
if (flag == 0) {
- PyErr_SetString(PyExc_TypeError, "bm.select_mode: cant assignt an empty value");
+ PyErr_SetString(PyExc_TypeError, "bm.select_mode: can't assign an empty value");
return -1;
}
@@ -1079,7 +1079,12 @@ PyDoc_STRVAR(
" :arg cage: Get the mesh as a deformed cage.\n"
" :type cage: boolean\n"
" :arg face_normals: Calculate face normals.\n"
- " :type face_normals: boolean\n");
+ " :type face_normals: boolean\n"
+ "\n"
+ " .. deprecated:: 2.93\n"
+ "\n"
+ " The deform parameter is deprecated, assumed to be True, and will be removed in version "
+ "3.0.\n");
static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject *kw)
{
static const char *kwlist[] = {"object", "depsgraph", "deform", "cage", "face_normals", NULL};
@@ -1120,45 +1125,36 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
return NULL;
}
+ if (use_deform == false) {
+ PyErr_WarnEx(PyExc_FutureWarning,
+ "from_object(...): the deform parameter is deprecated, assumed to be True, and "
+ "will be removed in version 3.0",
+ 1);
+ }
+
const bool use_render = DEG_get_mode(depsgraph) == DAG_EVAL_RENDER;
scene_eval = DEG_get_evaluated_scene(depsgraph);
ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bool need_free = false;
/* Write the display mesh into the dummy mesh */
- if (use_deform) {
- if (use_render) {
- if (use_cage) {
- PyErr_SetString(PyExc_ValueError,
- "from_object(...): cage arg is unsupported when dependency graph "
- "evaluation mode is RENDER");
- return NULL;
- }
-
- me_eval = BKE_mesh_new_from_object(depsgraph, ob_eval, true);
- need_free = true;
- }
- else {
- if (use_cage) {
- me_eval = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &data_masks);
- }
- else {
- me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &data_masks);
- }
- }
- }
- else {
- /* !use_deform */
+ if (use_render) {
if (use_cage) {
PyErr_SetString(PyExc_ValueError,
- "from_object(...): cage arg is unsupported when deform=False");
+ "from_object(...): cage arg is unsupported when dependency graph "
+ "evaluation mode is RENDER");
return NULL;
}
- if (use_render) {
- me_eval = mesh_create_eval_no_deform_render(depsgraph, scene_eval, ob, &data_masks);
+
+ me_eval = BKE_mesh_new_from_object(depsgraph, ob_eval, true);
+ need_free = true;
+ }
+ else {
+ if (use_cage) {
+ me_eval = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &data_masks);
}
else {
- me_eval = mesh_create_eval_no_deform(depsgraph, scene_eval, ob, &data_masks);
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &data_masks);
}
}
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index d944cb435d0..ec6b8c54ac0 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -865,11 +865,11 @@ bool PyC_NameSpace_ImportArray(PyObject *py_dict, const char *imports[])
}
/* restore MUST be called after this */
-void PyC_MainModule_Backup(PyObject **main_mod)
+void PyC_MainModule_Backup(PyObject **r_main_mod)
{
PyObject *modules = PyImport_GetModuleDict();
- *main_mod = PyDict_GetItemString(modules, "__main__");
- Py_XINCREF(*main_mod); /* don't free */
+ *r_main_mod = PyDict_GetItemString(modules, "__main__");
+ Py_XINCREF(*r_main_mod); /* don't free */
}
void PyC_MainModule_Restore(PyObject *main_mod)
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index f0875b82c3c..358123657c7 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -85,7 +85,7 @@ PyObject *PyC_DefaultNameSpace(const char *filename);
void PyC_RunQuicky(const char *filepath, int n, ...);
bool PyC_NameSpace_ImportArray(PyObject *py_dict, const char *imports[]);
-void PyC_MainModule_Backup(PyObject **main_mod);
+void PyC_MainModule_Backup(PyObject **r_main_mod);
void PyC_MainModule_Restore(PyObject *main_mod);
void PyC_SetHomePath(const char *py_path_bundle);
diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c
index 526b96f8584..b2603c75c3f 100644
--- a/source/blender/python/gpu/gpu_py_shader.c
+++ b/source/blender/python/gpu/gpu_py_shader.c
@@ -169,12 +169,12 @@ static PyObject *py_shader_uniform_block_from_name(BPyGPUShader *self, PyObject
return PyLong_FromLong(uniform);
}
-static bool py_shader_uniform_vector_imp(PyObject *args,
- int elem_size,
- int *r_location,
- int *r_length,
- int *r_count,
- Py_buffer *r_pybuffer)
+static bool py_shader_uniform_vector_impl(PyObject *args,
+ int elem_size,
+ int *r_location,
+ int *r_length,
+ int *r_count,
+ Py_buffer *r_pybuffer)
{
PyObject *buffer;
@@ -223,7 +223,7 @@ static PyObject *py_shader_uniform_vector_float(BPyGPUShader *self, PyObject *ar
Py_buffer pybuffer;
- if (!py_shader_uniform_vector_imp(args, sizeof(float), &location, &length, &count, &pybuffer)) {
+ if (!py_shader_uniform_vector_impl(args, sizeof(float), &location, &length, &count, &pybuffer)) {
return NULL;
}
@@ -244,7 +244,7 @@ static PyObject *py_shader_uniform_vector_int(BPyGPUShader *self, PyObject *args
Py_buffer pybuffer;
- if (!py_shader_uniform_vector_imp(args, sizeof(int), &location, &length, &count, &pybuffer)) {
+ if (!py_shader_uniform_vector_impl(args, sizeof(int), &location, &length, &count, &pybuffer)) {
return NULL;
}
@@ -570,9 +570,6 @@ PyDoc_STRVAR(
" ``GL_ARB_texture_gather``, ``GL_ARB_texture_cube_map_array``\n"
" and ``GL_ARB_shader_draw_parameters``.\n"
"\n"
- " To debug shaders, use the ``--debug-gpu-shaders`` command line option\n"
- " to see full GLSL shader compilation and linking errors.\n"
- "\n"
" For drawing user interface elements and gizmos, use\n"
" ``fragOutput = blender_srgb_to_framebuffer_space(fragOutput)``\n"
" to transform the output sRGB colors to the frame-buffer color-space.\n"
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index 02ab001dbf6..c7e195b586d 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -424,11 +424,6 @@ static PyGetSetDef bpy_app_getsets[] = {
bpy_app_debug_set,
bpy_app_debug_doc,
(void *)G_DEBUG_SIMDATA},
- {"debug_gpumem",
- bpy_app_debug_get,
- bpy_app_debug_set,
- bpy_app_debug_doc,
- (void *)G_DEBUG_GPU_MEM},
{"debug_io", bpy_app_debug_get, bpy_app_debug_set, bpy_app_debug_doc, (void *)G_DEBUG_IO},
{"use_event_simulate",
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index 1e81621246e..8ecee9b3f2e 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -286,7 +286,7 @@ void BPY_app_handlers_reset(const short do_all)
}
else {
/* remove */
- /* PySequence_DelItem(ls, i); */ /* more obvious buw slower */
+ /* PySequence_DelItem(ls, i); */ /* more obvious but slower */
PyList_SetSlice(ls, i, i + 1, NULL);
}
}
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 64e992bd76f..c4789407e4e 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -341,12 +341,20 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
}
}
- /* Without this the `sys.stdout` may be set to 'ascii'
- * (it is on my system at least), where printing unicode values will raise
- * an error, this is highly annoying, another stumbling block for developers,
- * so use a more relaxed error handler and enforce utf-8 since the rest of
- * Blender is utf-8 too - campbell */
- Py_SetStandardStreamEncoding("utf-8", "surrogateescape");
+ /* Force `utf-8` on all platforms, since this is what's used for Blender's internal strings,
+ * providing consistent encoding behavior across all Blender installations.
+ *
+ * This also uses the `surrogateescape` error handler ensures any unexpected bytes are escaped
+ * instead of raising an error.
+ *
+ * Without this `sys.getfilesystemencoding()` and `sys.stdout` for example may be set to ASCII
+ * or some other encoding - where printing some `utf-8` values will raise an error.
+ *
+ * This can cause scripts to fail entirely on some systems.
+ *
+ * This assignment is the equivalent of enabling the `PYTHONUTF8` environment variable.
+ * See `PEP-540` for details on exactly what this changes. */
+ Py_UTF8Mode = 1;
/* Suppress error messages when calculating the module search path.
* While harmless, it's noisy. */
diff --git a/source/blender/python/intern/bpy_interface_atexit.c b/source/blender/python/intern/bpy_interface_atexit.c
index 8e5a6dc530b..03d51b2fd59 100644
--- a/source/blender/python/intern/bpy_interface_atexit.c
+++ b/source/blender/python/intern/bpy_interface_atexit.c
@@ -42,7 +42,7 @@ static PyObject *bpy_atexit(PyObject *UNUSED(self), PyObject *UNUSED(args), PyOb
}
static PyMethodDef meth_bpy_atexit = {"bpy_atexit", (PyCFunction)bpy_atexit, METH_NOARGS, NULL};
-static PyObject *func_bpy_atregister = NULL; /* borrowed referebce, atexit holds */
+static PyObject *func_bpy_atregister = NULL; /* borrowed reference, `atexit` holds. */
static void atexit_func_call(const char *func_name, PyObject *atexit_func_arg)
{
diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c
index c6f0fbd3a2b..39d1fba2dc9 100644
--- a/source/blender/python/intern/bpy_library_load.c
+++ b/source/blender/python/intern/bpy_library_load.c
@@ -173,7 +173,7 @@ static PyTypeObject bpy_lib_Type = {
PyDoc_STRVAR(
bpy_lib_load_doc,
- ".. method:: load(filepath, link=False, relative=False)\n"
+ ".. method:: load(filepath, link=False, relative=False, assets_only=False)\n"
"\n"
" Returns a context manager which exposes 2 library objects on entering.\n"
" Each object has attributes matching bpy.data which are lists of strings to be linked.\n"
@@ -183,18 +183,28 @@ PyDoc_STRVAR(
" :arg link: When False reference to the original file is lost.\n"
" :type link: bool\n"
" :arg relative: When True the path is stored relative to the open blend file.\n"
- " :type relative: bool\n");
+ " :type relative: bool\n"
+ " :arg assets_only: If True, only list data-blocks marked as assets.\n"
+ " :type assets_only: bool\n");
static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
{
Main *bmain = CTX_data_main(BPY_context_get());
BPy_Library *ret;
const char *filename = NULL;
- bool is_rel = false, is_link = false;
-
- static const char *_keywords[] = {"filepath", "link", "relative", NULL};
- static _PyArg_Parser _parser = {"s|O&O&:load", _keywords, 0};
- if (!_PyArg_ParseTupleAndKeywordsFast(
- args, kw, &_parser, &filename, PyC_ParseBool, &is_link, PyC_ParseBool, &is_rel)) {
+ bool is_rel = false, is_link = false, use_assets_only = false;
+
+ static const char *_keywords[] = {"filepath", "link", "relative", "assets_only", NULL};
+ static _PyArg_Parser _parser = {"s|O&O&O&:load", _keywords, 0};
+ if (!_PyArg_ParseTupleAndKeywordsFast(args,
+ kw,
+ &_parser,
+ &filename,
+ PyC_ParseBool,
+ &is_link,
+ PyC_ParseBool,
+ &is_rel,
+ PyC_ParseBool,
+ &use_assets_only)) {
return NULL;
}
@@ -205,7 +215,8 @@ static PyObject *bpy_lib_load(PyObject *UNUSED(self), PyObject *args, PyObject *
BLI_path_abs(ret->abspath, BKE_main_blendfile_path(bmain));
ret->blo_handle = NULL;
- ret->flag = ((is_link ? FILE_LINK : 0) | (is_rel ? FILE_RELPATH : 0));
+ ret->flag = ((is_link ? FILE_LINK : 0) | (is_rel ? FILE_RELPATH : 0) |
+ (use_assets_only ? FILE_ASSETS_ONLY : 0));
ret->dict = _PyDict_NewPresized(MAX_LIBARRAY);
@@ -218,7 +229,8 @@ static PyObject *_bpy_names(BPy_Library *self, int blocktype)
LinkNode *l, *names;
int totnames;
- names = BLO_blendhandle_get_datablock_names(self->blo_handle, blocktype, &totnames);
+ names = BLO_blendhandle_get_datablock_names(
+ self->blo_handle, blocktype, (self->flag & FILE_ASSETS_ONLY) != 0, &totnames);
list = PyList_New(totnames);
if (names) {
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index a2125a5dff9..39ba8448795 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -605,7 +605,7 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr,
if (*r_prop_eul_order) {
const short order = RNA_property_enum_get(ptr, *r_prop_eul_order);
- /* Could be quat or axisangle. */
+ /* Could be quaternion or axis-angle. */
if (order >= EULER_ORDER_XYZ && order <= EULER_ORDER_ZYX) {
return order;
}
@@ -5051,7 +5051,7 @@ static PyObject *pyrna_prop_collection_find(BPy_PropertyRNA *self, PyObject *key
{
Py_ssize_t key_len_ssize_t;
const char *key = _PyUnicode_AsStringAndSize(key_ob, &key_len_ssize_t);
- const int key_len = (int)key_len_ssize_t; /* Comare with same type. */
+ const int key_len = (int)key_len_ssize_t; /* Compare with same type. */
char name[256], *nameptr;
int namelen;
@@ -5094,7 +5094,7 @@ static bool foreach_attr_type(BPy_PropertyRNA *self,
*r_attr_tot = 0;
*r_attr_signed = false;
- /* Note: this is fail with zero length lists, so don't let this get caled in that case. */
+ /* NOTE: this is fail with zero length lists, so don't let this get called in that case. */
RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) {
prop = RNA_struct_find_property(&itemptr, attr);
if (prop) {
@@ -8737,15 +8737,17 @@ void pyrna_free_types(void)
RNA_PROP_END;
}
-/* Note! MemLeak XXX
+/**
+ * \warning memory leak!
*
* There is currently a bug where moving the registration of a Python class does
- * not properly manage reference-counts from the Python class. As the srna owns
+ * not properly manage reference-counts from the Python class. As the `srna` owns
* the Python class this should not be so tricky, but changing the references as
* you'd expect when changing ownership crashes blender on exit so I had to comment out
- * the decref. This is not so bad because the leak only happens when re-registering (hold F8)
+ * the #Py_DECREF. This is not so bad because the leak only happens when re-registering
+ * (continuously running `SCRIPT_OT_reload`).
* - Should still be fixed - Campbell
- * */
+ */
PyDoc_STRVAR(pyrna_register_class_doc,
".. method:: register_class(cls)\n"
"\n"