New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test failure: test_tzlocal_offset_equal[GMT-tzoff1] (dateutil 2.8.0) #918
Comments
I would not expect the |
@pganssle I run two FreeBSD buildbots for Python core, which pass all tests on all branches (less any known regressions). To the extent that the time module is tested, I can confidently say yes. If there's some test case you'd like me to run on the system that exhibits the test failure reported here, I'm happy to run them and report back |
@koobs If you have a checkout of from dateutil.test._common import TZEnvContext
from dateutil import tz
from datetime import datetime
ts = 1560000000
print(datetime.fromtimestamp(1560000000, tz.tzlocal()))
with TZEnvContext("Pacific/Kiritimati"):
print(datetime.fromtimestamp(1560000000, tz.tzlocal())) Assuming you are not in |
|
@koobs Hm, so that's basically what I expected (though you're closer to Can you try this?
For me that prints |
For completeness I ran it under Python 3.6, in case the symptoms differed
|
@koobs Interesting, so it seems like the issue is in the way equality between How about this: from dateutil import tz
local = tz.tzlocal()
print(local._hasdst)
print(local._tznames[0])
print(local._std_offset) Can you run that with By the way, do you know of an easy way for me to get temporary access on a system like yours that is having this problem? It would probably be easier to debug than the high-latency method of "give you some debugging code and see how it works on your system" 😉. |
@pganssle Flick me a ssh pubkey and I'll create you an account on the machine reproducing the issue For the last high-latency debug request:
|
@koobs Sorry, I forgot to respond (I obviously lost interest as soon as we figured out the answer). I'm guessing that your system for some reason interprets I'm wondering if this is actually a violation of the POSIX standard on your OS's part, but we may as well find some workaround for it. One option might be to change that test to use |
@pganssle Analysis follows, thank you @RhodiumToad for your help digging/groking what we found: Your comment "GMT as equal to UTC", was close, but not quite the cause. It's not that GMT was equal to UTC, it was that "any non-present TZ name is the default timezone name". In FreeBSD's case ... Change localtime default from GMT -> UTC Original thread on the change: That change broke leapseconds because "If /usr/share/zoneinfo/GMT is absent, UTC leap seconds are loaded from /usr/share/zoneinfo/posixrules." until ... Change tzdata default from GMT -> UTC But didn't also create a Link Etc/GMT GMT POSIX does not recognize TZ=GMT or TZ=UTC as valid values because they neither start with a colon nor contain a numeric offset hour field: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html The default (upstream) tzdata comes with Etc/GMT and Etc/UTC, plus by default a link for GMT, plus a link for UTC if the "backward" file is installed, so UTC can't be relied upon in dateutil as a "works in all cases" We can take care of FreeBSD adding back a default GMT entry, which will take some time to make it into users hands for all supported releases. I would strongly suggest changes to dateutil to make it more robust at least to this particular class of intended behaviour, namely: Any TZ name expected to exist (explicitly), but doesn't, defaults to the Certainly, it does not necessarily have the same name, nor can or should that be asserted in tests, implicitly or otherwise. |
@koobs Thanks for getting to the bottom of that! That makes this way easier to solve from And also luckily this is just an invalid assumption in the test, not an invalid assumption in the software itself. |
@pganssle My pleasure. I can get it to pass with the following diff:
Is that the correct, full and complete change necessary? |
@koobs Yes, that looks good to me, if you would like to make a PR. If you don't mind, could you also add the line: ('UTC', tz.tzoffset('UTC', 0)), I think that it would be good to have a TZ environment variable that is not of the format |
@pganssle Can do |
I'm getting a test_tzoffset_weakref failure with that UTC TZ addition:
|
Shall we just leave this as a fix to the reported (GMT) issue? |
@koobs Yeah, we can save that for a separate issue. |
I'll create a PR at some point this weekend. Thank you for the support @pganssle |
Running into the following test failure while QA'ing dateutil 2.8.0 to update the FreeBSD port:
System/test environment is:
System timezone is Australia/Sydney:
I've tried setting
TZ=UTC
and TZ=other-non-utc-timezones
environment variables without affect.The text was updated successfully, but these errors were encountered: