need to be corrected for a negative index. */
#define PySequence_ITEM(o, i)\
( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) )
-
-/* === Mapping protocol ================================================= */
-
-// Convert Python int to Py_ssize_t. Do nothing if the argument is None.
-// Cannot be moved to the internal C API: used by Argument Clinic.
-PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *);
-
-// Same as PyNumber_Index but can return an instance of a subclass of int.
-// Cannot be moved to the internal C API: used by Argument Clinic.
-PyAPI_FUNC(PyObject *) _PyNumber_Index(PyObject *o);
extern int _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
+// Convert Python int to Py_ssize_t. Do nothing if the argument is None.
+// Export for '_bisect' shared extension.
+PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *);
+
+// Same as PyNumber_Index() but can return an instance of a subclass of int.
+// Export for 'math' shared extension.
+PyAPI_FUNC(PyObject*) _PyNumber_Index(PyObject *o);
#ifdef __cplusplus
}
*/
#include "Python.h"
+#include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(_io__BufferedIOBase_readinto__doc__,
"readinto($self, buffer, /)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=e5b335441452653d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=768c3a3a3deabcb4 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
PyDoc_STRVAR(_io_BytesIO_readable__doc__,
"readable($self, /)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=8d4e7651002e14c6 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6b1219bda0619e2a input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
PyDoc_STRVAR(_io_FileIO_close__doc__,
"close($self, /)\n"
#ifndef _IO_FILEIO_TRUNCATE_METHODDEF
#define _IO_FILEIO_TRUNCATE_METHODDEF
#endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
-/*[clinic end generated code: output=65b9a5cc96d193b6 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3a3c6ed7e5e78063 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
PyDoc_STRVAR(_io__IOBase_seek__doc__,
"seek($self, offset, whence=os.SEEK_SET, /)\n"
{
return _io__RawIOBase_readall_impl(self);
}
-/*[clinic end generated code: output=0f064cfd54e3c1a5 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ec741e0961671a86 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
PyDoc_STRVAR(_io_StringIO_getvalue__doc__,
"getvalue($self, /)\n"
{
return _io_StringIO_seekable_impl(self);
}
-/*[clinic end generated code: output=6f55dc1454aeb507 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=09d4056cc8c4aae4 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
PyDoc_STRVAR(_io__TextIOBase_detach__doc__,
"detach($self, /)\n"
{
return _io_TextIOWrapper_close_impl(self);
}
-/*[clinic end generated code: output=29b945b24287dd0c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c3a8eb2591be1bf7 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
#if defined(HAVE_WINDOWS_CONSOLE_IO)
#ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
#endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */
-/*[clinic end generated code: output=235393758365c229 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=0cdb16d95f1c7dac input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(_sre_getcodesize__doc__,
"getcodesize($module, /)\n"
}
return _sre_SRE_Scanner_search_impl(self, cls);
}
-/*[clinic end generated code: output=6b84e62c87238f0e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b8cf77f05e44d08c input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(_bisect_bisect_right__doc__,
"bisect_right($module, /, a, x, lo=0, hi=None, *, key=None)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=5a7fa64bf9b262f3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=839fdddeacdc2ecb input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(_bz2_BZ2Compressor_compress__doc__,
"compress($self, data, /)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=431fd0fc40f019d1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=40706688f92642b4 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(_collections__count_elements__doc__,
"_count_elements($module, mapping, iterable, /)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=00e516317d2b8bed input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d83188040656ad7c input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(_elementtree_Element_append__doc__,
"append($self, subelement, /)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=40767b1a98e54b60 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=0a34620406b95eb0 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(EVP_copy__doc__,
"copy($self, /)\n"
#ifndef _HASHLIB_SCRYPT_METHODDEF
#define _HASHLIB_SCRYPT_METHODDEF
#endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */
-/*[clinic end generated code: output=b339e255db698147 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=cfad8d5e904a4917 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(_lzma_LZMACompressor_compress__doc__,
"compress($self, data, /)\n"
return return_value;
}
-/*[clinic end generated code: output=aaf225a5d15d3e75 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f1a001f5f489c372 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(_operator_truth__doc__,
"truth($module, a, /)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=227cbcfed44f736e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=72bc63a775937245 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(_ssl__SSLSocket_do_handshake__doc__,
"do_handshake($self, /)\n"
#ifndef _SSL_ENUM_CRLS_METHODDEF
#define _SSL_ENUM_CRLS_METHODDEF
#endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
-/*[clinic end generated code: output=4c9f00c62f0825d2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6e2eb86330f3f9b8 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(Struct__doc__,
"Struct(format)\n"
return return_value;
}
-/*[clinic end generated code: output=f3d6e06f80368998 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=9b48aeaa86898ec5 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_long.h" // _PyLong_UnsignedShort_Converter()
PyDoc_STRVAR(test_empty_function__doc__,
exit:
return return_value;
}
-/*[clinic end generated code: output=41f439aab0cb809d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a652e6b1787d3346 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_long.h" // _PyLong_UnsignedShort_Converter()
PyDoc_STRVAR(depr_star_new__doc__,
exit:
return return_value;
}
-/*[clinic end generated code: output=22b59d92d517a8ec input=a9049054013a1b77]*/
+/*[clinic end generated code: output=464aeba97e482f5c input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(array_array___copy____doc__,
"__copy__($self, /)\n"
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
-/*[clinic end generated code: output=db417f5677a25eaa input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ab24c7a40a41c2e1 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
PyDoc_STRVAR(gc_enable__doc__,
"enable($module, /)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=16003cfbc66ada39 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=fe89ce0b90a1067d input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(batched_new__doc__,
"batched(iterable, n)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=111cbd102c2a23c9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=20999801c7349d2c input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_fileutils.h" // _PyLong_FileDescriptor_Converter()
#include "pycore_long.h" // _PyLong_UnsignedInt_Converter()
#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF
#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF
#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */
-/*[clinic end generated code: output=ff0e50316f4ed71a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=1b34619e5f65adc2 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(zlib_compress__doc__,
"compress($module, data, /, level=Z_DEFAULT_COMPRESSION, wbits=MAX_WBITS)\n"
#ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
#endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */
-/*[clinic end generated code: output=3eccb3f7265d53ba input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d574a79aa47c9969 input=a9049054013a1b77]*/
#endif
#include "Python.h"
+#include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_bitutils.h" // _Py_bit_length()
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_long.h" // _PyLong_GetZero()
#endif
#include <Python.h>
+#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
#include "pycore_bytesobject.h" // _PyBytes_Find()
#include "pycore_fileutils.h" // _Py_stat_struct
#ifdef __VXWORKS__
# include "pycore_bitutils.h" // _Py_popcount32()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_ceval.h" // _PyEval_ReInitThreads()
#include "pycore_fileutils.h" // _Py_closerange()
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
static int
bytearray___init___impl(PyByteArrayObject *self, PyObject *arg,
{
return bytearray_sizeof_impl(self);
}
-/*[clinic end generated code: output=cb94d7ac45f0a4b7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d388e9027b333f00 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(bytes___bytes____doc__,
"__bytes__($self, /)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=f4e85363c79c64d3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=9da56b6c04914e18 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(list_insert__doc__,
"insert($self, index, object, /)\n"
{
return list___reversed___impl(self);
}
-/*[clinic end generated code: output=2ca109d8acc775bc input=a9049054013a1b77]*/
+/*[clinic end generated code: output=537a17b562c57505 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
static PyObject *
long_new_impl(PyTypeObject *type, PyObject *x, PyObject *obase);
{
return int_is_integer_impl(self);
}
-/*[clinic end generated code: output=75ed306fff493ba1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ea9c87ea532dadbe input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(EncodingMap_size__doc__,
"size($self, /)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=2e1e1b136ef1b681 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a64776a3ea1c970c input=a9049054013a1b77]*/
for any kind of float exception without losing portability. */
#include "Python.h"
+#include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_dtoa.h" // _Py_dg_dtoa()
#include "pycore_floatobject.h" // _PyFloat_FormatAdvancedWriter()
#include "pycore_initconfig.h" // _PyStatus_OK()
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(stringlib_expandtabs__doc__,
"expandtabs($self, /, tabsize=8)\n"
exit:
return return_value;
}
-/*[clinic end generated code: output=00e34c03331699fe input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a0338b2d41671b17 input=a9049054013a1b77]*/
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_abstract.h" // _PyNumber_Index()
PyDoc_STRVAR(warnings_warn__doc__,
"warn($module, /, message, category=None, stacklevel=1, source=None, *,\n"
{
return warnings_filters_mutated_impl(module);
}
-/*[clinic end generated code: output=0e2b367a662bf51b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c8a6dc1403fba1d5 input=a9049054013a1b77]*/
/* New getargs implementation */
#include "Python.h"
+#include "pycore_abstract.h" // _PyNumber_Index()
#include "pycore_dict.h" // _PyDict_HasOnlyStringKeys()
#include "pycore_pylifecycle.h" // _PyArg_Fini
#include "pycore_tuple.h" // _PyTuple_ITEMS()
from . import common as _common
-# Modules/socketmodule.h uses pycore_time.h which needs the Py_BUILD_CORE
-# macro. Usually it's defined by the C file which includes it.
-# Other header files have a similar issue.
-NEED_BUILD_CORE = {
- # Header ".h" files
- 'cjkcodecs.h',
- 'multibytecodec.h',
- 'socketmodule.h',
-
- # Argument Clinic ".c.h" header files
- '_testclinic.c.h',
- '_testclinic_depr.c.h',
- '_winapi.c.h',
- 'fcntlmodule.c.h',
- 'overlapped.c.h',
- 'posixmodule.c.h',
- 'selectmodule.c.h',
- 'sha3module.c.h',
- 'termios.c.h',
-}
+# The following C files must not be built with Py_BUILD_CORE,
+# because they use the limited C API.
+USE_LIMITED_C_API = frozenset((
+ '_testcapimodule.c',
+ '_testclinic_limited.c',
+ 'xxlimited.c',
+ 'xxlimited_35.c',
+))
TOOL = 'gcc'
cwd = os.path.abspath(cwd or '.')
filename = _normpath(filename, cwd)
+ print(filename)
postargs = POST_ARGS
- if os.path.basename(filename) in NEED_BUILD_CORE:
+ if os.path.basename(filename) not in USE_LIMITED_C_API:
postargs += ('-DPy_BUILD_CORE=1',)
text = _common.preprocess(
if accept == {int}:
self.format_unit = 'n'
self.default_type = int
+ self.add_include('pycore_abstract.h', '_PyNumber_Index()')
elif accept == {int, NoneType}:
self.converter = '_Py_convert_optional_to_ssize_t'
+ self.add_include('pycore_abstract.h',
+ '_Py_convert_optional_to_ssize_t()')
else:
fail(f"Py_ssize_t_converter: illegal 'accept' argument {accept!r}")