Commit 6a29d9be authored by Simon Feltman's avatar Simon Feltman
Browse files

Add deprecation warning for marshaling arbitrary objects as pointers

Add deprecation warning for marshaling arbitrary objects to/from void
pointers with the exception of integers, PyCapsules, and None.

https://bugzilla.gnome.org/show_bug.cgi?id=688081
parent 077aefed
......@@ -251,9 +251,24 @@ _pygi_marshal_from_py_void (PyGIInvokeState *state,
{
g_warn_if_fail (arg_cache->transfer == GI_TRANSFER_NOTHING);
if (PYGLIB_CPointer_Check(py_arg)) {
if (py_arg == Py_None) {
arg->v_pointer = NULL;
} else if (PYGLIB_CPointer_Check(py_arg)) {
arg->v_pointer = PYGLIB_CPointer_GetPointer (py_arg, NULL);
} else {
/* NOTE: This will change to only allow integers and the deprecation
* warning will become a runtime exception. Using the following:
* arg->v_pointer = PyLong_AsVoidPtr (py_arg);
* See: https://bugzilla.gnome.org/show_bug.cgi?id=688081
*/
if (!PYGLIB_PyLong_Check(py_arg) && !PyLong_Check(py_arg)) {
if (PyErr_WarnEx(PyGIDeprecationWarning,
"Pointer arguments will be restricted to integers, capsules, and None. "
"See: https://bugzilla.gnome.org/show_bug.cgi?id=683599",
1))
return FALSE;
}
arg->v_pointer = py_arg;
}
......
......@@ -118,10 +118,16 @@ _pygi_marshal_to_py_void (PyGIInvokeState *state,
GIArgument *arg)
{
PyObject *py_obj = NULL;
if (arg_cache->is_pointer)
if (arg_cache->is_pointer) {
/* NOTE: This will change to interpret pointers as integer values
* by using the following:
* py_obj = PyLong_FromVoidPtr (arg->v_pointer);
* See: https://bugzilla.gnome.org/show_bug.cgi?id=688081
*/
py_obj = arg->v_pointer;
else
} else {
py_obj = Py_None;
}
Py_XINCREF (py_obj);
return py_obj;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment