Issue #18701: Remove support of old CPython versions (<3.0) from C code.
This commit is contained in:
parent
5c03d20757
commit
8fa8ee3970
|
@ -28,6 +28,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #18701: Remove support of old CPython versions (<3.0) from C code.
|
||||||
|
|
||||||
- Issue #18756: Improve error reporting in os.urandom() when the failure
|
- Issue #18756: Improve error reporting in os.urandom() when the failure
|
||||||
is due to something else than /dev/urandom not existing (for example,
|
is due to something else than /dev/urandom not existing (for example,
|
||||||
exhausting the file descriptor limit).
|
exhausting the file descriptor limit).
|
||||||
|
|
|
@ -428,13 +428,7 @@ CDataType_from_buffer(PyObject *type, PyObject *args)
|
||||||
StgDictObject *dict = PyType_stgdict(type);
|
StgDictObject *dict = PyType_stgdict(type);
|
||||||
assert (dict);
|
assert (dict);
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args,
|
if (!PyArg_ParseTuple(args, "O|n:from_buffer", &obj, &offset))
|
||||||
#if (PY_VERSION_HEX < 0x02050000)
|
|
||||||
"O|i:from_buffer",
|
|
||||||
#else
|
|
||||||
"O|n:from_buffer",
|
|
||||||
#endif
|
|
||||||
&obj, &offset))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (-1 == PyObject_AsWriteBuffer(obj, &buffer, &buffer_len))
|
if (-1 == PyObject_AsWriteBuffer(obj, &buffer, &buffer_len))
|
||||||
|
@ -447,11 +441,7 @@ CDataType_from_buffer(PyObject *type, PyObject *args)
|
||||||
}
|
}
|
||||||
if (dict->size > buffer_len - offset) {
|
if (dict->size > buffer_len - offset) {
|
||||||
PyErr_Format(PyExc_ValueError,
|
PyErr_Format(PyExc_ValueError,
|
||||||
#if (PY_VERSION_HEX < 0x02050000)
|
|
||||||
"Buffer size too small (%d instead of at least %d bytes)",
|
|
||||||
#else
|
|
||||||
"Buffer size too small (%zd instead of at least %zd bytes)",
|
"Buffer size too small (%zd instead of at least %zd bytes)",
|
||||||
#endif
|
|
||||||
buffer_len, dict->size + offset);
|
buffer_len, dict->size + offset);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -484,13 +474,7 @@ CDataType_from_buffer_copy(PyObject *type, PyObject *args)
|
||||||
StgDictObject *dict = PyType_stgdict(type);
|
StgDictObject *dict = PyType_stgdict(type);
|
||||||
assert (dict);
|
assert (dict);
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args,
|
if (!PyArg_ParseTuple(args, "O|n:from_buffer", &obj, &offset))
|
||||||
#if (PY_VERSION_HEX < 0x02050000)
|
|
||||||
"O|i:from_buffer",
|
|
||||||
#else
|
|
||||||
"O|n:from_buffer",
|
|
||||||
#endif
|
|
||||||
&obj, &offset))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (-1 == PyObject_AsReadBuffer(obj, (const void**)&buffer, &buffer_len))
|
if (-1 == PyObject_AsReadBuffer(obj, (const void**)&buffer, &buffer_len))
|
||||||
|
@ -504,11 +488,7 @@ CDataType_from_buffer_copy(PyObject *type, PyObject *args)
|
||||||
|
|
||||||
if (dict->size > buffer_len - offset) {
|
if (dict->size > buffer_len - offset) {
|
||||||
PyErr_Format(PyExc_ValueError,
|
PyErr_Format(PyExc_ValueError,
|
||||||
#if (PY_VERSION_HEX < 0x02050000)
|
|
||||||
"Buffer size too small (%d instead of at least %d bytes)",
|
|
||||||
#else
|
|
||||||
"Buffer size too small (%zd instead of at least %zd bytes)",
|
"Buffer size too small (%zd instead of at least %zd bytes)",
|
||||||
#endif
|
|
||||||
buffer_len, dict->size + offset);
|
buffer_len, dict->size + offset);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sqlitecompat.h"
|
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include "cursor.h"
|
#include "cursor.h"
|
||||||
#include "prepare_protocol.h"
|
#include "prepare_protocol.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "sqlitecompat.h"
|
|
||||||
|
|
||||||
#include "pythread.h"
|
#include "pythread.h"
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "cursor.h"
|
#include "cursor.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "sqlitecompat.h"
|
|
||||||
|
|
||||||
PyObject* pysqlite_cursor_iternext(pysqlite_Cursor* self);
|
PyObject* pysqlite_cursor_iternext(pysqlite_Cursor* self);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sqlitecompat.h"
|
|
||||||
#include "prepare_protocol.h"
|
#include "prepare_protocol.h"
|
||||||
|
|
||||||
int pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol* self, PyObject* args, PyObject* kwargs)
|
int pysqlite_prepare_protocol_init(pysqlite_PrepareProtocol* self, PyObject* args, PyObject* kwargs)
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#include "row.h"
|
#include "row.h"
|
||||||
#include "cursor.h"
|
#include "cursor.h"
|
||||||
#include "sqlitecompat.h"
|
|
||||||
|
|
||||||
void pysqlite_row_dealloc(pysqlite_Row* self)
|
void pysqlite_row_dealloc(pysqlite_Row* self)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "microprotocols.h"
|
#include "microprotocols.h"
|
||||||
#include "prepare_protocol.h"
|
#include "prepare_protocol.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "sqlitecompat.h"
|
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
static int pysqlite_check_remaining_sql(const char* tail);
|
static int pysqlite_check_remaining_sql(const char* tail);
|
||||||
|
|
|
@ -70,10 +70,6 @@ static char copyright[] =
|
||||||
/* enables copy/deepcopy handling (work in progress) */
|
/* enables copy/deepcopy handling (work in progress) */
|
||||||
#undef USE_BUILTIN_COPY
|
#undef USE_BUILTIN_COPY
|
||||||
|
|
||||||
#if PY_VERSION_HEX < 0x01060000
|
|
||||||
#define PyObject_DEL(op) PyMem_DEL((op))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
@ -1993,10 +1989,8 @@ join_list(PyObject* list, PyObject* string)
|
||||||
/* join list elements */
|
/* join list elements */
|
||||||
|
|
||||||
PyObject* joiner;
|
PyObject* joiner;
|
||||||
#if PY_VERSION_HEX >= 0x01060000
|
|
||||||
PyObject* function;
|
PyObject* function;
|
||||||
PyObject* args;
|
PyObject* args;
|
||||||
#endif
|
|
||||||
PyObject* result;
|
PyObject* result;
|
||||||
|
|
||||||
joiner = PySequence_GetSlice(string, 0, 0);
|
joiner = PySequence_GetSlice(string, 0, 0);
|
||||||
|
@ -2008,7 +2002,6 @@ join_list(PyObject* list, PyObject* string)
|
||||||
return joiner;
|
return joiner;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PY_VERSION_HEX >= 0x01060000
|
|
||||||
function = PyObject_GetAttrString(joiner, "join");
|
function = PyObject_GetAttrString(joiner, "join");
|
||||||
if (!function) {
|
if (!function) {
|
||||||
Py_DECREF(joiner);
|
Py_DECREF(joiner);
|
||||||
|
@ -2024,12 +2017,6 @@ join_list(PyObject* list, PyObject* string)
|
||||||
result = PyObject_CallObject(function, args);
|
result = PyObject_CallObject(function, args);
|
||||||
Py_DECREF(args); /* also removes list */
|
Py_DECREF(args); /* also removes list */
|
||||||
Py_DECREF(function);
|
Py_DECREF(function);
|
||||||
#else
|
|
||||||
result = call(
|
|
||||||
"string", "join",
|
|
||||||
PyTuple_Pack(2, list, joiner)
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
Py_DECREF(joiner);
|
Py_DECREF(joiner);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -2136,7 +2123,6 @@ error:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PY_VERSION_HEX >= 0x02020000
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
pattern_finditer(PatternObject* pattern, PyObject* args, PyObject* kw)
|
pattern_finditer(PatternObject* pattern, PyObject* args, PyObject* kw)
|
||||||
{
|
{
|
||||||
|
@ -2158,7 +2144,6 @@ pattern_finditer(PatternObject* pattern, PyObject* args, PyObject* kw)
|
||||||
|
|
||||||
return iterator;
|
return iterator;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
pattern_split(PatternObject* self, PyObject* args, PyObject* kw)
|
pattern_split(PatternObject* self, PyObject* args, PyObject* kw)
|
||||||
|
@ -2581,10 +2566,8 @@ static PyMethodDef pattern_methods[] = {
|
||||||
pattern_split_doc},
|
pattern_split_doc},
|
||||||
{"findall", (PyCFunction) pattern_findall, METH_VARARGS|METH_KEYWORDS,
|
{"findall", (PyCFunction) pattern_findall, METH_VARARGS|METH_KEYWORDS,
|
||||||
pattern_findall_doc},
|
pattern_findall_doc},
|
||||||
#if PY_VERSION_HEX >= 0x02020000
|
|
||||||
{"finditer", (PyCFunction) pattern_finditer, METH_VARARGS|METH_KEYWORDS,
|
{"finditer", (PyCFunction) pattern_finditer, METH_VARARGS|METH_KEYWORDS,
|
||||||
pattern_finditer_doc},
|
pattern_finditer_doc},
|
||||||
#endif
|
|
||||||
{"scanner", (PyCFunction) pattern_scanner, METH_VARARGS|METH_KEYWORDS},
|
{"scanner", (PyCFunction) pattern_scanner, METH_VARARGS|METH_KEYWORDS},
|
||||||
{"__copy__", (PyCFunction) pattern_copy, METH_NOARGS},
|
{"__copy__", (PyCFunction) pattern_copy, METH_NOARGS},
|
||||||
{"__deepcopy__", (PyCFunction) pattern_deepcopy, METH_O},
|
{"__deepcopy__", (PyCFunction) pattern_deepcopy, METH_O},
|
||||||
|
|
|
@ -24,13 +24,8 @@
|
||||||
#define STRINGLIB_CHECK PyUnicode_Check
|
#define STRINGLIB_CHECK PyUnicode_Check
|
||||||
#define STRINGLIB_CHECK_EXACT PyUnicode_CheckExact
|
#define STRINGLIB_CHECK_EXACT PyUnicode_CheckExact
|
||||||
|
|
||||||
#if PY_VERSION_HEX < 0x03000000
|
|
||||||
#define STRINGLIB_TOSTR PyObject_Unicode
|
|
||||||
#define STRINGLIB_TOASCII PyObject_Repr
|
|
||||||
#else
|
|
||||||
#define STRINGLIB_TOSTR PyObject_Str
|
#define STRINGLIB_TOSTR PyObject_Str
|
||||||
#define STRINGLIB_TOASCII PyObject_ASCII
|
#define STRINGLIB_TOASCII PyObject_ASCII
|
||||||
#endif
|
|
||||||
|
|
||||||
#define STRINGLIB_WANT_CONTAINS_OBJ 1
|
#define STRINGLIB_WANT_CONTAINS_OBJ 1
|
||||||
|
|
||||||
|
|
|
@ -554,10 +554,6 @@
|
||||||
RelativePath="..\..\Modules\_sqlite\row.h"
|
RelativePath="..\..\Modules\_sqlite\row.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\Modules\_sqlite\sqlitecompat.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\Modules\_sqlite\statement.h"
|
RelativePath="..\..\Modules\_sqlite\statement.h"
|
||||||
>
|
>
|
||||||
|
|
|
@ -243,7 +243,6 @@
|
||||||
<ClInclude Include="..\Modules\_sqlite\module.h" />
|
<ClInclude Include="..\Modules\_sqlite\module.h" />
|
||||||
<ClInclude Include="..\Modules\_sqlite\prepare_protocol.h" />
|
<ClInclude Include="..\Modules\_sqlite\prepare_protocol.h" />
|
||||||
<ClInclude Include="..\Modules\_sqlite\row.h" />
|
<ClInclude Include="..\Modules\_sqlite\row.h" />
|
||||||
<ClInclude Include="..\Modules\_sqlite\sqlitecompat.h" />
|
|
||||||
<ClInclude Include="..\Modules\_sqlite\statement.h" />
|
<ClInclude Include="..\Modules\_sqlite\statement.h" />
|
||||||
<ClInclude Include="..\Modules\_sqlite\util.h" />
|
<ClInclude Include="..\Modules\_sqlite\util.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -30,9 +30,6 @@
|
||||||
<ClInclude Include="..\Modules\_sqlite\row.h">
|
<ClInclude Include="..\Modules\_sqlite\row.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\Modules\_sqlite\sqlitecompat.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\Modules\_sqlite\statement.h">
|
<ClInclude Include="..\Modules\_sqlite\statement.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
Loading…
Reference in New Issue