]> granicus.if.org Git - python/commitdiff
Issue #9369: The types of `char*` arguments of PyObject_CallFunction() and
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 29 May 2013 15:50:54 +0000 (18:50 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 29 May 2013 15:50:54 +0000 (18:50 +0300)
PyObject_CallMethod() now changed to `const char*`.
Based on patches by Jörg Müller and Lars Buitinck.

Doc/c-api/object.rst
Doc/data/refcounts.dat
Include/abstract.h
Misc/ACKS
Misc/NEWS
Objects/abstract.c

index 02a0d36499f01387bd5e73c21e3fdd0d1b1e1668..791cdbb042b9e2431601b17f15b11547c228d9a4 100644 (file)
@@ -240,7 +240,7 @@ is considered sufficient for this determination.
    of the Python expression ``callable_object(*args)``.
 
 
-.. c:function:: PyObject* PyObject_CallFunction(PyObject *callable, char *format, ...)
+.. c:function:: PyObject* PyObject_CallFunction(PyObject *callable, const char *format, ...)
 
    Call a callable Python object *callable*, with a variable number of C arguments.
    The C arguments are described using a :c:func:`Py_BuildValue` style format
@@ -250,8 +250,11 @@ is considered sufficient for this determination.
    pass :c:type:`PyObject \*` args, :c:func:`PyObject_CallFunctionObjArgs` is a
    faster alternative.
 
+   .. versionchanged:: 3.4
+      The type of *format* was changed from ``char *``.
 
-.. c:function:: PyObject* PyObject_CallMethod(PyObject *o, char *method, char *format, ...)
+
+.. c:function:: PyObject* PyObject_CallMethod(PyObject *o, const char *method, const char *format, ...)
 
    Call the method named *method* of object *o* with a variable number of C
    arguments.  The C arguments are described by a :c:func:`Py_BuildValue` format
@@ -261,6 +264,9 @@ is considered sufficient for this determination.
    Note that if you only pass :c:type:`PyObject \*` args,
    :c:func:`PyObject_CallMethodObjArgs` is a faster alternative.
 
+   .. versionchanged:: 3.4
+      The types of *method* and *format* were changed from ``char *``.
+
 
 .. c:function:: PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ..., NULL)
 
index f298238d1689804b8ceb8157aa9d65643960a97b..0b56fe5da204bdc825d2483c538e8fcc12d55ec0 100644 (file)
@@ -218,7 +218,7 @@ PyDict_GetItem:PyObject*:key:0:
 
 PyDict_GetItemString:PyObject*::0:
 PyDict_GetItemString:PyObject*:p:0:
-PyDict_GetItemString:char*:key::
+PyDict_GetItemString:const char*:key::
 
 PyDict_SetDefault:PyObject*::0:
 PyDict_SetDefault:PyObject*:p:0:
@@ -917,7 +917,7 @@ PyObject_Call:PyObject*:kw:0:
 
 PyObject_CallFunction:PyObject*::+1:
 PyObject_CallFunction:PyObject*:callable_object:0:
-PyObject_CallFunction:char*:format::
+PyObject_CallFunction:const char*:format::
 PyObject_CallFunction::...::
 
 PyObject_CallFunctionObjArgs:PyObject*::+1:
@@ -926,8 +926,8 @@ PyObject_CallFunctionObjArgs::...::
 
 PyObject_CallMethod:PyObject*::+1:
 PyObject_CallMethod:PyObject*:o:0:
-PyObject_CallMethod:char*:m::
-PyObject_CallMethod:char*:format::
+PyObject_CallMethod:const char*:m::
+PyObject_CallMethod:const char*:format::
 PyObject_CallMethod::...::
 
 PyObject_CallMethodObjArgs:PyObject*::+1:
index 6f1691399aefe987e7f43975d9abcc9ead72450e..6516bfeb8a049a63954b8d6561944be7b5b5cbd1 100644 (file)
@@ -284,7 +284,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
        */
 
      PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable_object,
-                                                  char *format, ...);
+                                                  const char *format, ...);
 
        /*
      Call a callable Python object, callable_object, with a
@@ -296,8 +296,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
        */
 
 
-     PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *o, char *method,
-                                                char *format, ...);
+     PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *o,
+                                                const char *method,
+                                                const char *format, ...);
 
        /*
      Call the method named m of object o with a variable number of
@@ -308,8 +309,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
      Python expression: o.method(args).
        */
 
-     PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *o, _Py_Identifier *method,
-                                                  char *format, ...);
+     PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *o,
+                                                   _Py_Identifier *method,
+                                                   const char *format, ...);
 
        /*
          Like PyObject_CallMethod, but expect a _Py_Identifier* as the
@@ -317,13 +319,16 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
        */
 
      PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable,
-                                                         char *format, ...);
+                                                         const char *format,
+                                                         ...);
      PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *o,
-                                                       char *name,
-                                                       char *format, ...);
+                                                       const char *name,
+                                                       const char *format,
+                                                       ...);
      PyAPI_FUNC(PyObject *) _PyObject_CallMethodId_SizeT(PyObject *o,
                                                        _Py_Identifier *name,
-                                                       char *format, ...);
+                                                       const char *format,
+                                                       ...);
 
      PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable,
                                                          ...);
index 1f589812c6bef953fee4c425e333839bb2ff98db..9ba99cd7c68f08c1e9873e6b90a0367989acce55 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -174,6 +174,7 @@ Floris Bruynooghe
 Stan Bubrouski
 Erik de Bueger
 Jan-Hein Bührman
+Lars Buitinck
 Dick Bulterman
 Bill Bumgarner
 Jimmy Burgett
@@ -872,6 +873,7 @@ Neil Muller
 Louis Munro
 R. David Murray
 Matti Mäki
+Jörg Müller
 Dale Nagata
 John Nagle
 Takahiro Nakayama
index 3b9416b5627dc98230780a705aada4aa4a704bd5..c71388e8ac7c5829f9bfbcfaab693da407b8b3bc 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -387,6 +387,10 @@ Tests
 C-API
 -----
 
+- Issue #9369: The types of `char*` arguments of PyObject_CallFunction() and
+  PyObject_CallMethod() now changed to `const char*`.  Based on patches by
+  Jörg Müller and Lars Buitinck.
+
 - Issue #17206: Py_CLEAR(), Py_DECREF(), Py_XINCREF() and Py_XDECREF() now
   expand their arguments once instead of multiple times.  Patch written by Illia
   Polosukhin.
index 0934b950f0c7d5c39f06de471272ce98d8e1a910..40ea43bc8d389cbdc19a072f25837c1e1432eabd 100644 (file)
@@ -2142,7 +2142,7 @@ call_function_tail(PyObject *callable, PyObject *args)
 }
 
 PyObject *
-PyObject_CallFunction(PyObject *callable, char *format, ...)
+PyObject_CallFunction(PyObject *callable, const char *format, ...)
 {
     va_list va;
     PyObject *args;
@@ -2162,7 +2162,7 @@ PyObject_CallFunction(PyObject *callable, char *format, ...)
 }
 
 PyObject *
-_PyObject_CallFunction_SizeT(PyObject *callable, char *format, ...)
+_PyObject_CallFunction_SizeT(PyObject *callable, const char *format, ...)
 {
     va_list va;
     PyObject *args;
@@ -2182,7 +2182,7 @@ _PyObject_CallFunction_SizeT(PyObject *callable, char *format, ...)
 }
 
 static PyObject*
-callmethod(PyObject* func, char *format, va_list va, int is_size_t)
+callmethod(PyObject* func, const char *format, va_list va, int is_size_t)
 {
     PyObject *retval = NULL;
     PyObject *args;
@@ -2211,7 +2211,7 @@ callmethod(PyObject* func, char *format, va_list va, int is_size_t)
 }
 
 PyObject *
-PyObject_CallMethod(PyObject *o, char *name, char *format, ...)
+PyObject_CallMethod(PyObject *o, const char *name, const char *format, ...)
 {
     va_list va;
     PyObject *func = NULL;
@@ -2232,7 +2232,8 @@ PyObject_CallMethod(PyObject *o, char *name, char *format, ...)
 }
 
 PyObject *
-_PyObject_CallMethodId(PyObject *o, _Py_Identifier *name, char *format, ...)
+_PyObject_CallMethodId(PyObject *o, _Py_Identifier *name,
+                       const char *format, ...)
 {
     va_list va;
     PyObject *func = NULL;
@@ -2253,7 +2254,8 @@ _PyObject_CallMethodId(PyObject *o, _Py_Identifier *name, char *format, ...)
 }
 
 PyObject *
-_PyObject_CallMethod_SizeT(PyObject *o, char *name, char *format, ...)
+_PyObject_CallMethod_SizeT(PyObject *o, const char *name,
+                           const char *format, ...)
 {
     va_list va;
     PyObject *func = NULL;
@@ -2273,7 +2275,8 @@ _PyObject_CallMethod_SizeT(PyObject *o, char *name, char *format, ...)
 }
 
 PyObject *
-_PyObject_CallMethodId_SizeT(PyObject *o, _Py_Identifier *name, char *format, ...)
+_PyObject_CallMethodId_SizeT(PyObject *o, _Py_Identifier *name,
+                             const char *format, ...)
 {
     va_list va;
     PyObject *func = NULL;