summaryrefslogtreecommitdiffstats
path: root/Objects/bytesobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-08 00:01:56 (GMT)
committerGitHub <noreply@github.com>2020-04-08 00:01:56 (GMT)
commita15e260b708a98edaba86a2aa663c3f6b2abc964 (patch)
treeac80e678c0266db42f8264a1fccfdeb1f58f6a17 /Objects/bytesobject.c
parent45ec5b99aefa54552947049086e87ec01bc2fc9a (diff)
downloadcpython-a15e260b708a98edaba86a2aa663c3f6b2abc964.zip
cpython-a15e260b708a98edaba86a2aa663c3f6b2abc964.tar.gz
cpython-a15e260b708a98edaba86a2aa663c3f6b2abc964.tar.bz2
bpo-40170: Add _PyIndex_Check() internal function (GH-19426)
Add _PyIndex_Check() function to the internal C API: fast inlined verson of PyIndex_Check(). Add Include/internal/pycore_abstract.h header file. Replace PyIndex_Check() with _PyIndex_Check() in C files of Objects and Python subdirectories.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r--Objects/bytesobject.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index bd8af72..03cd7dd 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -3,6 +3,7 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
+#include "pycore_abstract.h" // _PyIndex_Check()
#include "pycore_bytes_methods.h"
#include "pycore_object.h"
#include "pycore_pymem.h"
@@ -1579,7 +1580,7 @@ bytes_hash(PyBytesObject *a)
static PyObject*
bytes_subscript(PyBytesObject* self, PyObject* item)
{
- if (PyIndex_Check(item)) {
+ if (_PyIndex_Check(item)) {
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
if (i == -1 && PyErr_Occurred())
return NULL;
@@ -2536,7 +2537,7 @@ bytes_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
/* Is it an integer? */
- if (PyIndex_Check(x)) {
+ if (_PyIndex_Check(x)) {
size = PyNumber_AsSsize_t(x, PyExc_OverflowError);
if (size == -1 && PyErr_Occurred()) {
if (!PyErr_ExceptionMatches(PyExc_TypeError))