bpo-34392: Add sys. _is_interned() (GH-8755)

This commit is contained in:
Serhiy Storchaka 2023-12-04 11:09:06 +02:00 • committed by GitHub
parent 0e732d0997
commit dee7beeb4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 87 additions and 1 deletions

View file

@ -289,6 +289,40 @@ exit:
return return_value;
}
PyDoc_STRVAR(sys__is_interned__doc__,
"_is_interned($module, string, /)\n"
"--\n"
"\n"
"Return True if the given string is \"interned\".");
#define SYS__IS_INTERNED_METHODDEF \
{"_is_interned", (PyCFunction)sys__is_interned, METH_O, sys__is_interned__doc__},
static int
sys__is_interned_impl(PyObject *module, PyObject *string);
static PyObject *
sys__is_interned(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *string;
int _return_value;
if (!PyUnicode_Check(arg)) {
_PyArg_BadArgument("_is_interned", "argument", "str", arg);
goto exit;
}
string = arg;
_return_value = sys__is_interned_impl(module, string);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyBool_FromLong((long)_return_value);
exit:
return return_value;
}
PyDoc_STRVAR(sys__settraceallthreads__doc__,
"_settraceallthreads($module, arg, /)\n"
"--\n"
@ -1452,4 +1486,4 @@ exit:
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
#define SYS_GETANDROIDAPILEVEL_METHODDEF
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
/*[clinic end generated code: output=f36d45c829250775 input=a9049054013a1b77]*/
/*[clinic end generated code: output=3dc3b2cb0ce38ebb input=a9049054013a1b77]*/