Skip to content

Commit 4c0c877

Browse files
committed
bpo-37645: rename PyObject_FunctionStr() -> _PyObject_FunctionStr()
1 parent 733158d commit 4c0c877

File tree

7 files changed

+13
-15
lines changed

7 files changed

+13
-15
lines changed

Doc/c-api/object.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Object Protocol
197197
does not silently discard an active exception.
198198
199199
200-
.. c:function:: PyObject* PyObject_FunctionStr(PyObject *func)
200+
.. c:function:: PyObject* _PyObject_FunctionStr(PyObject *func)
201201
202202
Return a user-friendly string representation of the function-like object
203203
*func*. This returns ``func.__qualname__ + "()"`` if there is a

Include/cpython/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static inline void _Py_Dealloc_inline(PyObject *op)
348348
}
349349
#define _Py_Dealloc(op) _Py_Dealloc_inline(op)
350350

351-
PyAPI_FUNC(PyObject *) PyObject_FunctionStr(PyObject *);
351+
PyAPI_FUNC(PyObject *) _PyObject_FunctionStr(PyObject *);
352352

353353
/* Safely decref `op` and set `op` to `op2`.
354354
*
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Add :c:func:`PyObject_FunctionStr` to get a user-friendly string representation
1+
Add :c:func:`_PyObject_FunctionStr` to get a user-friendly string representation
22
of a function-like object.

Objects/descrobject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ method_check_args(PyObject *func, PyObject *const *args, Py_ssize_t nargs, PyObj
236236
{
237237
assert(!PyErr_Occurred());
238238
if (nargs < 1) {
239-
PyObject *funcstr = PyObject_FunctionStr(func);
239+
PyObject *funcstr = _PyObject_FunctionStr(func);
240240
if (funcstr != NULL) {
241241
PyErr_Format(PyExc_TypeError,
242242
"%U needs an argument", funcstr);
@@ -250,7 +250,7 @@ method_check_args(PyObject *func, PyObject *const *args, Py_ssize_t nargs, PyObj
250250
return -1;
251251
}
252252
if (kwnames && PyTuple_GET_SIZE(kwnames)) {
253-
PyObject *funcstr = PyObject_FunctionStr(func);
253+
PyObject *funcstr = _PyObject_FunctionStr(func);
254254
if (funcstr != NULL) {
255255
PyErr_Format(PyExc_TypeError,
256256
"%U takes no keyword arguments", funcstr);
@@ -375,7 +375,7 @@ method_vectorcall_NOARGS(
375375
return NULL;
376376
}
377377
if (nargs != 1) {
378-
PyObject *funcstr = PyObject_FunctionStr(func);
378+
PyObject *funcstr = _PyObject_FunctionStr(func);
379379
if (funcstr != NULL) {
380380
PyErr_Format(PyExc_TypeError,
381381
"%U takes no arguments (%zd given)", funcstr, nargs-1);
@@ -401,7 +401,7 @@ method_vectorcall_O(
401401
return NULL;
402402
}
403403
if (nargs != 2) {
404-
PyObject *funcstr = PyObject_FunctionStr(func);
404+
PyObject *funcstr = _PyObject_FunctionStr(func);
405405
if (funcstr != NULL) {
406406
PyErr_Format(PyExc_TypeError,
407407
"%U takes exactly one argument (%zd given)",

Objects/methodobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ cfunction_check_kwargs(PyObject *func, PyObject *kwnames)
338338
assert(!PyErr_Occurred());
339339
assert(PyCFunction_Check(func));
340340
if (kwnames && PyTuple_GET_SIZE(kwnames)) {
341-
PyObject *funcstr = PyObject_FunctionStr(func);
341+
PyObject *funcstr = _PyObject_FunctionStr(func);
342342
if (funcstr != NULL) {
343343
PyErr_Format(PyExc_TypeError,
344344
"%U takes no keyword arguments", funcstr);
@@ -403,7 +403,7 @@ cfunction_vectorcall_NOARGS(
403403
}
404404
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
405405
if (nargs != 0) {
406-
PyObject *funcstr = PyObject_FunctionStr(func);
406+
PyObject *funcstr = _PyObject_FunctionStr(func);
407407
if (funcstr != NULL) {
408408
PyErr_Format(PyExc_TypeError,
409409
"%U takes no arguments (%zd given)", funcstr, nargs);
@@ -429,7 +429,7 @@ cfunction_vectorcall_O(
429429
}
430430
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
431431
if (nargs != 1) {
432-
PyObject *funcstr = PyObject_FunctionStr(func);
432+
PyObject *funcstr = _PyObject_FunctionStr(func);
433433
if (funcstr != NULL) {
434434
PyErr_Format(PyExc_TypeError,
435435
"%U takes exactly one argument (%zd given)", funcstr, nargs);

Objects/object.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,14 +665,14 @@ PyObject_Bytes(PyObject *v)
665665

666666

667667
/*
668-
def PyObject_FunctionStr(f):
668+
def _PyObject_FunctionStr(f):
669669
try:
670670
return f.__qualname__ + "()"
671671
except Exception:
672672
return type(f).__name__ + " object"
673673
*/
674674
PyObject *
675-
PyObject_FunctionStr(PyObject *f)
675+
_PyObject_FunctionStr(PyObject *f)
676676
{
677677
_Py_IDENTIFIER(__qualname__);
678678
PyObject *name = _PyObject_GetAttrId(f, &PyId___qualname__);
@@ -683,8 +683,6 @@ PyObject_FunctionStr(PyObject *f)
683683
}
684684
/* __qualname__ lookup failed */
685685
if (!PyErr_ExceptionMatches(PyExc_Exception)) {
686-
/* An exception not inheriting from Exception, like KeyboardInterrupt.
687-
* Propagate it. */
688686
return NULL;
689687
}
690688
PyErr_Clear();

Python/ceval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5344,7 +5344,7 @@ check_args_iterable(PyThreadState *tstate, PyObject *func, PyObject *args)
53445344
/* check_args_iterable() may be called with a live exception,
53455345
* clear it. */
53465346
PyErr_Clear();
5347-
PyObject *funcstr = PyObject_FunctionStr(func);
5347+
PyObject *funcstr = _PyObject_FunctionStr(func);
53485348
if (funcstr != NULL) {
53495349
_PyErr_Format(tstate, PyExc_TypeError,
53505350
"%U argument after * must be an iterable, not %.200s",

0 commit comments

Comments
 (0)