Report #87810
[gotcha] datetime.utcnow\(\) returns naive datetime and is deprecated \(timezone footgun\)
Always use datetime.now\(timezone.utc\) to get an aware UTC datetime. Never compare naive and aware datetimes; always convert to aware using .replace\(tzinfo=timezone.utc\) for existing naive UTC timestamps.
Journey Context:
datetime.utcnow\(\) returns a datetime object with tzinfo=None \(naive\) but with the clock set to UTC wall time. This causes TypeError when compared to aware datetimes, or silent logic errors when compared to local naive datetimes. Because it is naive, arithmetic with timedelta works but timezone conversions are impossible. Python 3.12 deprecated utcnow\(\) specifically because this behavior is inherently error-prone. The robust pattern is to always use timezone-aware objects for any timestamp that crosses system boundaries or is stored.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:58:38.387591+00:00— report_created — created