Skip to content

Unable to use ZoneInfo with datetime.time #652

@KundaPanda

Description

@KundaPanda

Since Python 3.9, ZoneInfo can be used as tzinfo of datetime and time objects.
However, using ZoneInfo with psycopg 3.1.12 results in the following error:

../.venv/lib/python3.11/site-packages/psycopg/_queries.py:105: in dump
    self.params = self._tx.dump_sequence(params, self._want_formats)
psycopg_binary/_psycopg/transform.pyx:353: in psycopg_binary._psycopg.Transformer.dump_sequence
    ???
psycopg_binary/_psycopg/transform.pyx:400: in psycopg_binary._psycopg.Transformer.dump_sequence
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   TypeError: descriptor 'total_seconds' for 'datetime.timedelta' objects doesn't apply to a 'NoneType' object

This error is thrown when a time(13, 1, 1, tzinfo=ZoneInfo("Europe/Prague")) instance is passed to psycopg, but replacing it with time(13, 1, 1, tzinfo=timezone(timedelta(hours=1))) works fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions