Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-133940: test_strftime incorrectly calculates expected week#134281
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
python-cla-botbot commentedMay 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
This is a test change so no NEWS entry needed |
jan1 = time.struct_time( | ||
( | ||
now.tm_year, # Year | ||
1, # Month (January) | ||
1, # Day (1st) | ||
0, # Hour (0) | ||
0, # Minute (0) | ||
0, # Second (0) | ||
-1, # tm_wday (will be determined) | ||
1, # tm_yday (day 1 of the year) | ||
-1, # tm_isdst (let the system determine) | ||
) | ||
) | ||
# use mktime to get the correct tm_wday and tm_isdst values | ||
self.jan1 = time.localtime(time.mktime(jan1)) |
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.
jan1=time.struct_time( | |
( | |
now.tm_year,# Year | |
1,# Month (January) | |
1,# Day (1st) | |
0,# Hour (0) | |
0,# Minute (0) | |
0,# Second (0) | |
-1,# tm_wday (will be determined) | |
1,# tm_yday (day 1 of the year) | |
-1,# tm_isdst (let the system determine) | |
) | |
) | |
# use mktime to get the correct tm_wday and tm_isdst values | |
self.jan1=time.localtime(time.mktime(jan1)) | |
self.jan1=time.localtime(time.mktime((now[0],1,1,0,0,0,-1,1,-1))) |
Why not just all on one line like before, it seems clear to me, and this is a test after all.
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.
FWIW I like the long version myself.
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.
IMO it is overkill and distracting, if you are looking at these tests you are probably familiar withstruct_time
anyway.
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 can confirm it works. I changed the buildbot config so running it here will be of no use.
!buildbot raspbian |
StanFromIreland commentedMay 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@gpshead There is no point unless you have changed the config on yours? It seems buildbot is down right now too. |
e3dda8f
intopython:mainUh oh!
There was an error while loading.Please reload this page.
…ythonGH-134281)Let the system determine the correct tm_wday and tm_isdst.(cherry picked from commite3dda8f)Co-authored-by: Gustaf <79180496+GGyll@users.noreply.github.com>
…ythonGH-134281)Let the system determine the correct tm_wday and tm_isdst.(cherry picked from commite3dda8f)Co-authored-by: Gustaf <79180496+GGyll@users.noreply.github.com>
GH-134301 is a backport of this pull request to the3.14 branch. |
GH-134302 is a backport of this pull request to the3.13 branch. |
Uh oh!
There was an error while loading.Please reload this page.
self.jan1 results to January 1st 2024 if set to Irish Time Zone. By letting time.mktime correct the tm_wday and tm_isdst values we can prevent this and we will always get the current year.
test_strftime
incorrectly calculates expected week #133940