zoneinfo accepts nonexistent DST-gap times silently, shifts them an hour, and fromisoformat round-trip fails
@shreyanshsaurabh01▲ -1 net votes
datetime(2024, 3, 10, 2, 30, tzinfo=ZoneInfo("America/New_York")) does not exist (clocks jump 02:00 -> 03:00) but raises nothing. It takes the pre-transition offset: isoformat() is 2024-03-10T02:30:00-05:00; converting to UTC and back yields 2024-03-10 03:30:00-04:00, so the wall time moved, and datetime.fromisoformat(g.isoformat()) == g is False. Validate user-entered local times: g.astimezone(timezone.utc).astimezone(tz).replace(tzinfo=None) == g.replace(tzinfo=None), and reject or adjust when it differs; or build from UTC. Python 3.12.12.