Skip to content

fix: store SqliteCache timestamps as ISO text - #1508

Open
cvas22 wants to merge 1 commit into
mvantellingen:mainfrom
cvas22:sqlite-datetime
Open

cvas22 wants to merge 1 commit into
mvantellingen:mainfrom
cvas22:sqlite-datetime

Conversation

@cvas22

@cvas22 cvas22 commented Nov 15, 2026

Copy link
Copy Markdown

Fixes #1507.

SqliteCache now writes the timestamp as ISO text itself and parses it with datetime.fromisoformat in get(), instead of going through sqlite3's default adapter and converter. That gets rid of the deprecation warnings on 3.12+ and fixes the ValueError when an entry is cached on a whole second. Existing cache files keep working, since fromisoformat reads what the old adapter wrote, with or without the UTC offset.

Notes

I added tests for the whole-second case, for rows in the old formats, and one that checks no sqlite3 deprecation warning is raised. The suite passes on 3.10 and 3.15. This is independent of #1506.

Don't rely on sqlite3's default datetime adapter and converter, which
are deprecated since Python 3.12 and fail to parse timestamps without
microseconds. Rows written by older versions still read fine.

Fixes mvantellingen#1507

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows cache upgrade check for 1be9eed (CPython 3.12.16 x64, SQLite 3.53.1), run with Codex.

Zeep 4.2.1 and 4.3.3 each wrote an on-disk cache through SqliteCache.add(), with one whole-second timestamp and one fractional-second timestamp per file. On main (1b7072c), reading the whole-second entry from 4.3.3 reproduced #1507: ValueError: invalid literal for int() with base 10: b'00+00'. The other three entries were readable.

On the PR, all four entries returned their original bytes at exactly the 60-second timeout and returned None one microsecond later. Both database files were byte-identical after the reads. The PR read both timestamp formats (with and without the UTC offset) with deprecation warnings treated as errors.

python -m pytest -q tests/test_cache.py passed all 17 tests on the PR. The only warning came from the existing pytest.yield_fixture in tests/conftest.py.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SqliteCache uses deprecated sqlite3 datetime adapters and fails on whole-second timestamps

2 participants