Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix sqlite timezone-naive adapter recipe #131825

Open
Labels
docsDocumentation in the Doc dirtopic-sqlite3type-bugAn unexpected behavior, bug, or error
@drf5n

Description

@drf5n

Documentation

This recipe for an adapter does not work as advertised:

   def adapt_datetime_iso(val):       """Adapt datetime.datetime to timezone-naive ISO 8601 date."""       return val.isoformat()

from:https://github.com/erlend-aasland/cpython/blob/a3711d1541c1b7987941b41d2247f87dae347117/Doc/library/sqlite3.rst?plain=1#L2287-L2289
orhttps://docs.python.org/3/library/sqlite3.html#sqlite3-adapter-converter-recipes

If the argument has a timezone, it will produce a timezone-aware result, contrary to its documentation
Consider the difference between these:

import datetimeprint(datetime.datetime.now(datetime.timezone.utc).isoformat())print(datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None).isoformat())"""2025-03-28T08:41:09.240880+00:002025-03-28T08:41:09.241046"""

The recipe should instead be like this:

   def adapt_datetime_iso(val):       """Adapt datetime.datetime to timezone-naive ISO 8601 date."""       return val.replace(tzinfo=None).isoformat()

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirtopic-sqlite3type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp