Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-92434: Silence a compiler warning in _sqlite/connection.c for 32bit version #93090

Merged
merged 8 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:meth:`~sqlite3.Connection.serialize` raises :exc:`OverflowError` on 32bit Python
when more than ``Py_SSIZE_T_MAX`` bytes of serialization occurs.
neonene marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 8 additions & 1 deletion Modules/_sqlite/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -2091,7 +2091,14 @@ serialize_impl(pysqlite_Connection *self, const char *name)
name);
return NULL;
}
PyObject *res = PyBytes_FromStringAndSize(data, size);
#if PY_SSIZE_T_MAX < 9223372036854775807
erlend-aasland marked this conversation as resolved.
Show resolved Hide resolved
if (size > PY_SSIZE_T_MAX) {
neonene marked this conversation as resolved.
Show resolved Hide resolved
PyErr_Format(PyExc_OverflowError,
"serialized '%s' too large to convert to bytes", name);
return NULL;
}
#endif
PyObject *res = PyBytes_FromStringAndSize(data, (Py_ssize_t)size);
if (!(flags & SQLITE_SERIALIZE_NOCOPY)) {
sqlite3_free((void *)data);
}
Expand Down