#293·AI-Trader

zoneinfo fallback in price_fetcher is unreachable and catches the wrong exception

Author: LudwigJMarxCreated Sep 21, 2026Updated Sep 21, 2026

Summary

price_fetcher guards the America/New_York lookup with except ImportError. ZoneInfo("America/New_York") raises ZoneInfoNotFoundError, which inherits from KeyError, so on a system without a tz database the module fails to import instead of falling back.

Where

service/server/price_fetcher.py:18-22

python
try:
    from zoneinfo import ZoneInfo
    _ET_ZONEINFO = ZoneInfo("America/New_York")
except ImportError:
    _ET_ZONEINFO = None  # Python < 3.9 fallback: use fixed offset below

ET_TZ (:48) is used for US stock timestamps at :800, :860 and :914.

Environment

Commit d03ff6c
Python 3.14.7
OS macOS 26.6.2, arm64

Reproduction

>>> import zoneinfo
>>> [c.__name__ for c in zoneinfo.ZoneInfoNotFoundError.__mro__]
['ZoneInfoNotFoundError', 'KeyError', 'LookupError', 'Exception', 'BaseException', 'object']
>>> issubclass(zoneinfo.ZoneInfoNotFoundError, ImportError)
False
>>> zoneinfo.reset_tzpath([])
>>> zoneinfo.ZoneInfo('America/New_York')
zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key America/New_York'

Two further points:

  • The comment names Python < 3.9 as the case to cover. service/requirements.txt pins fastapi>=0.109.0 and pydantic>=2.5.3, and the codebase uses X | Y annotations, so 3.9 is not a supported target and zoneinfo is always importable.
  • If the fallback did run, timezone(timedelta(hours=-5)) is EST year round, so US market timestamps would be off by one hour for the roughly eight months of DST.

Not verified

  • Not reproduced on a real tzdata-less host (Alpine, or Windows without the tzdata package). The class hierarchy and the reset_tzpath result above are from CPython 3.14.7 on macOS.
  • Whether the operators run such a host is unknown; service/requirements.txt does not pin tzdata.