You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There may be a regression in Structlog 25.2.0 as a result of #709. My unit tests found that it always displays time in local timezone, even if you set flag utc=True. For ISO format it works fine, but for custom format, it strips the UTC timezone and applies a local one.
Before applying astimezone() the object has UTC timezone, then it is replaced by local timezone. As per datetime documentation:
If called without arguments (or with tz=None) the system local time zone is assumed for the target time zone.
Not sure if this is intentional, but this behavior changed from Structlog 25.1.0. How about handling UTC separately, the same way it is done for ISO format?
Unfortunately your bug report came ~24h too late and I’m now on vacation for three weeks. Skimming your report looks like you’re right, but I don’t think it warrants a yank on PyPI?
I would welcome a PR with an appropriate new test. The approach to have separate stamper()s makes sense.
Sure, why not. Testing this is not very easy, because freezegun does not handle timezones correctly. At least not in a way that could guarantee the same test results when the tests themselves are executed across many timezones.
Please enjoy your vacation and take a look when you're back. No need to hurry.
Pull request #713
Hello,
There may be a regression in Structlog 25.2.0 as a result of #709. My unit tests found that it always displays time in local timezone, even if you set flag
utc=True
. For ISO format it works fine, but for custom format, it strips the UTC timezone and applies a local one.Easiest way to reproduce is:
In
structlog/src/structlog/processors.py
TimeStamper(fmt="%Y-%m-%d %H:%M:%S %Z", utc=True)
effectively does:datetime.datetime.now(tz=datetime.timezone.utc).astimezone()
Before applying astimezone() the object has UTC timezone, then it is replaced by local timezone. As per datetime documentation:
If called without arguments (or with tz=None) the system local time zone is assumed for the target time zone.
Not sure if this is intentional, but this behavior changed from Structlog 25.1.0. How about handling UTC separately, the same way it is done for ISO format?
Let me know if this makes sense or I misconfigured something,
Thanks,
Marcin Endraszka
The text was updated successfully, but these errors were encountered: