Skip to content

Commit

Permalink
Changes for Cython 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed Jul 18, 2023
1 parent 16901b0 commit 83c6b78
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions playhouse/_sqlite_ext.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ ctypedef struct peewee_cursor:
# We define an xConnect function, but leave xCreate NULL so that the
# table-function can be called eponymously.
cdef int pwConnect(sqlite3 *db, void *pAux, int argc, const char *const*argv,
sqlite3_vtab **ppVtab, char **pzErr) with gil:
sqlite3_vtab **ppVtab, char **pzErr) noexcept with gil:
cdef:
int rc
object table_func_cls = <object>pAux
Expand All @@ -407,7 +407,7 @@ cdef int pwConnect(sqlite3 *db, void *pAux, int argc, const char *const*argv,
return rc


cdef int pwDisconnect(sqlite3_vtab *pBase) with gil:
cdef int pwDisconnect(sqlite3_vtab *pBase) noexcept with gil:
cdef:
peewee_vtab *pVtab = <peewee_vtab *>pBase
object table_func_cls = <object>(pVtab.table_func_cls)
Expand All @@ -419,7 +419,8 @@ cdef int pwDisconnect(sqlite3_vtab *pBase) with gil:

# The xOpen method is used to initialize a cursor. In this method we
# instantiate the TableFunction class and zero out a new cursor for iteration.
cdef int pwOpen(sqlite3_vtab *pBase, sqlite3_vtab_cursor **ppCursor) with gil:
cdef int pwOpen(sqlite3_vtab *pBase, sqlite3_vtab_cursor **ppCursor) \
noexcept with gil:
cdef:
peewee_vtab *pVtab = <peewee_vtab *>pBase
peewee_cursor *pCur = <peewee_cursor *>0
Expand All @@ -443,7 +444,7 @@ cdef int pwOpen(sqlite3_vtab *pBase, sqlite3_vtab_cursor **ppCursor) with gil:
return SQLITE_OK


cdef int pwClose(sqlite3_vtab_cursor *pBase) with gil:
cdef int pwClose(sqlite3_vtab_cursor *pBase) noexcept with gil:
cdef:
peewee_cursor *pCur = <peewee_cursor *>pBase
object table_func = <object>pCur.table_func
Expand All @@ -454,7 +455,7 @@ cdef int pwClose(sqlite3_vtab_cursor *pBase) with gil:

# Iterate once, advancing the cursor's index and assigning the row data to the
# `row_data` field on the peewee_cursor struct.
cdef int pwNext(sqlite3_vtab_cursor *pBase) with gil:
cdef int pwNext(sqlite3_vtab_cursor *pBase) noexcept with gil:
cdef:
peewee_cursor *pCur = <peewee_cursor *>pBase
object table_func = <object>pCur.table_func
Expand Down Expand Up @@ -483,7 +484,7 @@ cdef int pwNext(sqlite3_vtab_cursor *pBase) with gil:

# Return the requested column from the current row.
cdef int pwColumn(sqlite3_vtab_cursor *pBase, sqlite3_context *ctx,
int iCol) with gil:
int iCol) noexcept with gil:
cdef:
bytes bval
peewee_cursor *pCur = <peewee_cursor *>pBase
Expand All @@ -502,15 +503,15 @@ cdef int pwColumn(sqlite3_vtab_cursor *pBase, sqlite3_context *ctx,
return python_to_sqlite(ctx, row_data[iCol])


cdef int pwRowid(sqlite3_vtab_cursor *pBase, sqlite3_int64 *pRowid):
cdef int pwRowid(sqlite3_vtab_cursor *pBase, sqlite3_int64 *pRowid) noexcept:
cdef:
peewee_cursor *pCur = <peewee_cursor *>pBase
pRowid[0] = <sqlite3_int64>pCur.idx
return SQLITE_OK


# Return a boolean indicating whether the cursor has been consumed.
cdef int pwEof(sqlite3_vtab_cursor *pBase):
cdef int pwEof(sqlite3_vtab_cursor *pBase) noexcept:
cdef:
peewee_cursor *pCur = <peewee_cursor *>pBase
return 1 if pCur.stopped else 0
Expand All @@ -520,7 +521,8 @@ cdef int pwEof(sqlite3_vtab_cursor *pBase):
# get access to the parameters that the function was called with, and call the
# TableFunction's `initialize()` function.
cdef int pwFilter(sqlite3_vtab_cursor *pBase, int idxNum,
const char *idxStr, int argc, sqlite3_value **argv) with gil:
const char *idxStr, int argc, sqlite3_value **argv) \
noexcept with gil:
cdef:
peewee_cursor *pCur = <peewee_cursor *>pBase
object table_func = <object>pCur.table_func
Expand Down Expand Up @@ -572,7 +574,7 @@ cdef int pwFilter(sqlite3_vtab_cursor *pBase, int idxNum,
# SQLite will (in some cases, repeatedly) call the xBestIndex method to try and
# find the best query plan.
cdef int pwBestIndex(sqlite3_vtab *pBase, sqlite3_index_info *pIdxInfo) \
with gil:
noexcept with gil:
cdef:
int i
int col_idx
Expand Down

0 comments on commit 83c6b78

Please sign in to comment.