Skip to content
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

Modernize stat usage #4627

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Modernize stat usage #4627

wants to merge 2 commits into from

Conversation

mwichmann
Copy link
Collaborator

Since Python 2.2, the object returned by an os.stat() call presents attributes matching the 10-tuple of stat values. Use these instead of indexing into the tuple (which is now considered "backwards-compatibility" mode).

As usual for non-removed tests, minor tweaks made if needed - copyright header and DefautlEnvironment() call for performance.

This change has no visibility into docs.

Contributor Checklist:

  • I have created a new test or updated the unit tests to cover the new/changed functionality.
  • I have updated CHANGES.txt and RELEASE.txt (and read the README.rst).
  • I have updated the appropriate documentation

@mwichmann mwichmann added the maintenance Tasks to maintain internal SCons code/tools label Nov 8, 2024
@mwichmann
Copy link
Collaborator Author

mwichmann commented Nov 8, 2024

Hmmm, problems went undetected because my dev machine wasn't reporting results properly due to previous virtualenv damage I thought I'd finished repairing. Will sort out shortly.

@mwichmann
Copy link
Collaborator Author

Ah... affects sconsign - stat_result returns floats for times, but using the backwards-compat indexing form returns ints, because that's what it did back in the earliest days. So that mismatch is tripping things up in the sconsign tests.

Since Python 2.2, the object returned by an os.stat() call presents
attributes matching the 10-tuple of stat values. Use these instead of
indexing into the tuple.

As usual for non-removed tests, minor tweaks made if needed -
copyright header and DefautlEnvironment() call for performance.

Signed-off-by: Mats Wichmann <[email protected]>
If a stat_result object's st_*time attributes are used, a float is
returned instead of an int. Adjust sconsign test regexes to optionally
accept a .digits tail of the number.  Confirmed this works for both
indexed attributes (which return an int) and named attributes (float).

Signed-off-by: Mats Wichmann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Tasks to maintain internal SCons code/tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant