OSError would be enough to solve the problem reported in #371. However,
in case of error, Windows C implementation segfaults. I would prefer to
not chase this error just because of weirdness in the tzdata external
library, so let's cast a wider net.
Fix #371
sname = tzname.decode() if tzname else "UTC"
try:
zi: tzinfo = ZoneInfo(sname)
- except KeyError:
+ except (KeyError, OSError):
logger.warning("unknown PostgreSQL timezone: %r; will use UTC", sname)
zi = timezone.utc
sname = tzname.decode() if tzname else "UTC"
try:
zi = ZoneInfo(sname)
- except KeyError:
+ except (KeyError, OSError):
logger = logging.getLogger("psycopg")
logger.warning(
"unknown PostgreSQL timezone: %r; will use UTC", sname