rogerbinns / apsw

Another Python SQLite wrapper
https://rogerbinns.github.io/apsw/
Other
715 stars 96 forks source link

error: static declaration of ‘PyLong_AsInt’ in Python 3.13+ #511

Closed dfateyev closed 3 months ago

dfateyev commented 3 months ago

Fedora packagers have notified that apsw experiences build issues, starting from Python 3.13 alpha:

In file included from src/apsw.c:161:
src/pyutil.c:150:1: error: static declaration of ‘PyLong_AsInt’ follows non-static declaration
  150 | PyLong_AsInt(PyObject *val)
      | ^~~~~~~~~~~~
src/argparse.c: In function ‘argcheck_bool’:
src/pyutil.c:252:9: error: implicit declaration of function ‘_PyErr_ChainExceptions’; did you mean ‘PyErr_NewException’? [-Wimplicit-function-declaration]
  252 |         _PyErr_ChainExceptions(_e1, _e2, _e3); \
      |         ^~~~~~~~~~~~~~~~~~~~~~
In file included from src/apsw.c:173:
src/statementcache.c: In function ‘statementcache_prepare_internal’:
src/statementcache.c:179:12: error: implicit declaration of function ‘_Py_HashBytes’ [-Wimplicit-function-declaration]
  179 |     hash = _Py_HashBytes(utf8, utf8size);
      |            ^~~~~~~~~~~~~

https://docs.python.org/3.13/whatsnew/3.13.html

https://bugzilla.redhat.com/show_bug.cgi?id=2263165

rogerbinns commented 3 months ago

@dfateyev Thanks for alerting me to this. I had been checking Python 3.13 issues on an ad-hoc basis, but have now added it to my release procedures, which happen every 1 to 3 months.

PyLong_AsInt was addressed in this commit which was in APSW 3.43.2.0 released October 24, 2023. See releases.

I've added a prototype for C extension chaining exceptions as a workaround, until Python decides what to do.

I've replaced the call to _Py_HashBytes with an internal hash function.

The first change, plus the latter two fix all errors and warnings when compiling with Python 3.13 alpha 5, and are now on APSW master. They will be part of the next APSW release.

How would you like these fixes delivered? APSW currently requires SQLite 3.44 released 2023-11-01.

dfateyev commented 3 months ago

@rogerbinns thanks for the fixes. Good to know that it's all tracked. I think we have time till Python 3.13 is stabilized and provided in Linux distributions. Once the next APSW is released, I will recheck its build against an actual alpha version of Python 3.13 (they may change anything additionally by that time).

rogerbinns commented 3 months ago

Ok, I'll close this this issue but add a comment on the next APSW release (should be less than a month of two) just as confirmation. The Python team are addressing the chain exceptions API problem.