From: Daniele Varrazzo Date: Wed, 14 Sep 2022 11:59:14 +0000 (+0100) Subject: docs: mention Windows timezone problem fixed in change log X-Git-Tag: 3.1.2~9^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48143be0327a08c22271c181fc6019efac33601f;p=thirdparty%2Fpsycopg.git docs: mention Windows timezone problem fixed in change log --- diff --git a/docs/news.rst b/docs/news.rst index 810d9ba83..a77d7a6ca 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -7,6 +7,16 @@ ``psycopg`` release notes ========================= +Future releases +--------------- + +Psycopg 3.1.2 (unreleased) +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Fix handling of certain invalid time zones causing problems on Windows + (:ticket:`#371`). + + Current release --------------- diff --git a/psycopg/psycopg/_tz.py b/psycopg/psycopg/_tz.py index 58c815686..813ed6261 100644 --- a/psycopg/psycopg/_tz.py +++ b/psycopg/psycopg/_tz.py @@ -31,6 +31,14 @@ def get_tzinfo(pgconn: Optional[PGconn]) -> tzinfo: except (KeyError, OSError): logger.warning("unknown PostgreSQL timezone: %r; will use UTC", sname) zi = timezone.utc + except Exception as ex: + logger.warning( + "error handling PostgreSQL timezone: %r; will use UTC (%s - %s)", + sname, + type(ex).__name__, + ex, + ) + zi = timezone.utc _timezones[tzname] = zi return zi diff --git a/psycopg_c/psycopg_c/types/datetime.pyx b/psycopg_c/psycopg_c/types/datetime.pyx index 5d32a66d3..9f1bc3caf 100644 --- a/psycopg_c/psycopg_c/types/datetime.pyx +++ b/psycopg_c/psycopg_c/types/datetime.pyx @@ -1110,6 +1110,14 @@ cdef object _timezone_from_connection(pq.PGconn pgconn): "unknown PostgreSQL timezone: %r; will use UTC", sname ) zi = timezone_utc + except Exception as ex: + logger.warning( + "error handling PostgreSQL timezone: %r; will use UTC (%s - %s)", + sname, + type(ex).__name__, + ex, + ) + zi = timezone.utc _timezones[tzname] = zi return zi