summaryrefslogtreecommitdiffstats
path: root/Objects/stringlib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-05-28 07:33:45 (GMT)
committerGitHub <noreply@github.com>2020-05-28 07:33:45 (GMT)
commit5f4b229df7812f1788287095eb6b138bb21876a4 (patch)
treef00cef402d0467010a34e9e617d89ccebebe6d1a /Objects/stringlib
parenteaca2aa117d663acf8160a0b4543ee2c7006fcc7 (diff)
downloadcpython-5f4b229df7812f1788287095eb6b138bb21876a4.zip
cpython-5f4b229df7812f1788287095eb6b138bb21876a4.tar.gz
cpython-5f4b229df7812f1788287095eb6b138bb21876a4.tar.bz2
bpo-40792: Make the result of PyNumber_Index() always having exact type int. (GH-20443)
Previously, the result could have been an instance of a subclass of int. Also revert bpo-26202 and make attributes start, stop and step of the range object having exact type int. Add private function _PyNumber_Index() which preserves the old behavior of PyNumber_Index() for performance to use it in the conversion functions like PyLong_AsLong().
Diffstat (limited to 'Objects/stringlib')
-rw-r--r--Objects/stringlib/clinic/transmogrify.h.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/Objects/stringlib/clinic/transmogrify.h.h b/Objects/stringlib/clinic/transmogrify.h.h
index 8dd7e6b..a5135a0 100644
--- a/Objects/stringlib/clinic/transmogrify.h.h
+++ b/Objects/stringlib/clinic/transmogrify.h.h
@@ -70,7 +70,7 @@ stringlib_ljust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}
{
Py_ssize_t ival = -1;
- PyObject *iobj = PyNumber_Index(args[0]);
+ PyObject *iobj = _PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
@@ -126,7 +126,7 @@ stringlib_rjust(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}
{
Py_ssize_t ival = -1;
- PyObject *iobj = PyNumber_Index(args[0]);
+ PyObject *iobj = _PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
@@ -182,7 +182,7 @@ stringlib_center(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}
{
Py_ssize_t ival = -1;
- PyObject *iobj = PyNumber_Index(args[0]);
+ PyObject *iobj = _PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
@@ -234,7 +234,7 @@ stringlib_zfill(PyObject *self, PyObject *arg)
{
Py_ssize_t ival = -1;
- PyObject *iobj = PyNumber_Index(arg);
+ PyObject *iobj = _PyNumber_Index(arg);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
@@ -249,4 +249,4 @@ stringlib_zfill(PyObject *self, PyObject *arg)
exit:
return return_value;
}
-/*[clinic end generated code: output=cd5ecdbf1d9e849a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=2d9abc7b1cffeca6 input=a9049054013a1b77]*/