-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
bpo-35317: Fix mktime() error in test_email #10721
Conversation
Fix mktime() overflow error in test_email: run test_localtime_daylight_true_dst_true() and test_localtime_daylight_false_dst_true() with a specific timezone.
I tested manually the fix on FreeBSD 12.0-RC2 and Fedora Rawhide with TZ=UTC: the change fix test_email. |
@bitdancer, @abalkin, @pganssle: Would you mind to review this change? |
This will still blow up outside of test environment, when I have UTC timezone:
Shouldn't the exception be nicer? E.g.: ValueError: You cannot have DST when you have UTC timezone. |
That's expected. Python exposes the behavior of the OS. The PR only fix test_email, it doesn't touch time nor datetime modules. |
Hm, I was not aware of this |
@@ -75,13 +75,15 @@ def test_localtime_daylight_false_dst_false(self): | |||
t2 = utils.localtime(t1) | |||
self.assertEqual(t1, t2) | |||
|
|||
@test.support.run_with_tz('Europe/Minsk') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like an odd choice of test time zone, but the choice is essentially arbitrary, so I have no real problem with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's copied from other tests at the bottom fo the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reused a timezone which is already used in other tests, so I don't have to pick a different timezone ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minsk is an odd choice to pin this test on, but as long as the test is specifically pointing at some time in the past I think it is pretty safe to leave it in Europe/Minsk
, since it is not likely that DST will be found to have not been in effect on this particular date.
Sorry, I don't know the origin of this helper and I don't know the function. Feel free to propose an enhancement :-) I only care of fixing the test ;-) |
Python is a thin wrapper to the C function mktime() which only sets errno to EOVERFLOW on error: "The result cannot be represented". The function doesn't tell where the error comes from. |
@vstinner Yes, hopefully we can get a "local time" |
Adding a "local timezone" feature directly to datetime would be great, but I have no idea how to do that :-) |
@vstinner @hroncok I agree with Miro that Maybe we can open up a new bug on the issue tracker (if one doesn't exist) to address the exception raised in UTC. I'm pretty confident that at the very least I recommend a new PR for a new issue that starts by adding a new test that is effectively the same as the one that throws an error, but pins the time zone to |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7. |
Fix mktime() overflow error in test_email: run test_localtime_daylight_true_dst_true() and test_localtime_daylight_false_dst_true() with a specific timezone. (cherry picked from commit cfaafda) Co-authored-by: Victor Stinner <vstinner@redhat.com>
GH-10741 is a backport of this pull request to the 3.7 branch. |
GH-10742 is a backport of this pull request to the 3.6 branch. |
Fix mktime() overflow error in test_email: run test_localtime_daylight_true_dst_true() and test_localtime_daylight_false_dst_true() with a specific timezone. (cherry picked from commit cfaafda) Co-authored-by: Victor Stinner <vstinner@redhat.com>
Fix mktime() overflow error in test_email: run test_localtime_daylight_true_dst_true() and test_localtime_daylight_false_dst_true() with a specific timezone. (cherry picked from commit cfaafda) Co-authored-by: Victor Stinner <vstinner@redhat.com>
Fix mktime() overflow error in test_email: run test_localtime_daylight_true_dst_true() and test_localtime_daylight_false_dst_true() with a specific timezone. (cherry picked from commit cfaafda) Co-authored-by: Victor Stinner <vstinner@redhat.com>
Fix mktime() overflow error in test_email: run
test_localtime_daylight_true_dst_true() and
test_localtime_daylight_false_dst_true() with a specific timezone.
https://bugs.python.org/issue35317