[Python-checkins] cpython: make _PyNumber_ConvertIntegralToInt static, since it's only used in abstract.c
benjamin.peterson
python-checkins at python.org
Wed Mar 21 19:51:51 CET 2012
http://hg.python.org/cpython/rev/1e89e2c86df0
changeset: 75857:1e89e2c86df0
user: Benjamin Peterson <benjamin at python.org>
date: Wed Mar 21 14:44:43 2012 -0400
summary:
make _PyNumber_ConvertIntegralToInt static, since it's only used in abstract.c
files:
Include/abstract.h | 15 ---------------
Objects/abstract.c | 14 ++++++++++----
2 files changed, 10 insertions(+), 19 deletions(-)
diff --git a/Include/abstract.h b/Include/abstract.h
--- a/Include/abstract.h
+++ b/Include/abstract.h
@@ -773,21 +773,6 @@
PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc);
/*
- Returns the Integral instance converted to an int. The
- instance is expected to be int or long or have an __int__
- method. Steals integral's reference. error_format will be
- used to create the TypeError if integral isn't actually an
- Integral instance. error_format should be a format string
- that can accept a char* naming integral's type.
- */
-
-#ifndef Py_LIMITED_API
- PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt(
- PyObject *integral,
- const char* error_format);
-#endif
-
- /*
Returns the object converted to Py_ssize_t by going through
PyNumber_Index first. If an overflow error occurs while
converting the int-or-long to Py_ssize_t, then the second argument
diff --git a/Objects/abstract.c b/Objects/abstract.c
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -1268,8 +1268,15 @@
}
-PyObject *
-_PyNumber_ConvertIntegralToInt(PyObject *integral, const char* error_format)
+/*
+ Returns the Integral instance converted to an int. The instance is expected
+ to be an int or have an __int__ method. Steals integral's
+ reference. error_format will be used to create the TypeError if integral
+ isn't actually an Integral instance. error_format should be a format string
+ that can accept a char* naming integral's type.
+*/
+static PyObject *
+convert_integral_to_int(PyObject *integral, const char *error_format)
{
PyNumberMethods *nb;
if (PyLong_Check(integral))
@@ -1345,8 +1352,7 @@
Py_DECREF(trunc_func);
/* __trunc__ is specified to return an Integral type,
but long() needs to return a long. */
- int_instance = _PyNumber_ConvertIntegralToInt(
- truncated,
+ int_instance = convert_integral_to_int(truncated,
"__trunc__ returned non-Integral (type %.200s)");
return int_instance;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list