summaryrefslogtreecommitdiffstats
path: root/Objects/clinic/unicodeobject.c.h
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/clinic/unicodeobject.c.h
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/clinic/unicodeobject.c.h')
-rw-r--r--Objects/clinic/unicodeobject.c.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h
index 2d81730..ecd409e 100644
--- a/Objects/clinic/unicodeobject.c.h
+++ b/Objects/clinic/unicodeobject.c.h
@@ -88,7 +88,7 @@ unicode_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);
@@ -522,7 +522,7 @@ unicode_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);
@@ -717,7 +717,7 @@ unicode_replace(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
}
{
Py_ssize_t ival = -1;
- PyObject *iobj = PyNumber_Index(args[2]);
+ PyObject *iobj = _PyNumber_Index(args[2]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
@@ -831,7 +831,7 @@ unicode_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);
@@ -900,7 +900,7 @@ unicode_split(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject
}
{
Py_ssize_t ival = -1;
- PyObject *iobj = PyNumber_Index(args[1]);
+ PyObject *iobj = _PyNumber_Index(args[1]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
@@ -997,7 +997,7 @@ unicode_rsplit(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject
}
{
Py_ssize_t ival = -1;
- PyObject *iobj = PyNumber_Index(args[1]);
+ PyObject *iobj = _PyNumber_Index(args[1]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
@@ -1193,7 +1193,7 @@ unicode_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);
@@ -1258,4 +1258,4 @@ unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return unicode_sizeof_impl(self);
}
-/*[clinic end generated code: output=ea1aff10c743be14 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c5eb21e314da78b8 input=a9049054013a1b77]*/