Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Nov 5, 2025

Disable the fast path on systems with 32-bit long.

Disable the fast path on systems with 32-bit long.
@vstinner
Copy link
Member Author

vstinner commented Nov 5, 2025

Fix the warnings:

./Modules/posixmodule.c:2638:31: warning: comparison is always true due to limited range of data type [-Wtype-limits]
./Modules/posixmodule.c:2638:45: warning: comparison is always true due to limited range of data type [-Wtype-limits]

cc @cmaloney @jbosboom

@vstinner
Copy link
Member Author

vstinner commented Nov 5, 2025

!buildbot x86 Debian

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @vstinner for commit c86068e 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F141043%2Fmerge

The command will test the builders whose names match following regular expression: x86 Debian

The builders matched are:

  • x86 Debian Installed with X PR
  • x86 Debian Non-Debug with X PR

@vstinner
Copy link
Member Author

vstinner commented Nov 5, 2025

https://buildbot.python.org/#/builders/1285/builds/530 confirms that the compiler warnings on Modules/posixmodule.c are gone.

@vstinner
Copy link
Member Author

vstinner commented Nov 5, 2025

On 32-bit, the fast path is not interesting, it only covers seconds in the range [-3; 2]:

>>> -2**31 // 1_000_000_000
-3
>>> (2**31-1) // 1_000_000_000
2

@vstinner vstinner merged commit 30ab627 into python:main Nov 5, 2025
50 checks passed
@vstinner vstinner deleted the statx_sec_to_ns branch November 5, 2025 17:31
static PyObject *
stat_nanosecond_timestamp(_posixstate *state, time_t sec, unsigned long nsec)
{
#if SIZEOF_LONG >= 8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think this is correct. The comparison is always true, not always false if SIZEOF_LONG < 8.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind to elaborate? I'm not sure that I understand your remark. What do you suggest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, if SIZEOF_LONG < 8, the fast path PyLong_FromLongLong(sec * SEC_TO_NS + nsec) was always used. Now it is never used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote a different fix: #141069

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that I now understood my mistake. Sorry about that :-( I read LONG_MIN (32-bit) instead of LLONG_MIN (64-bit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants