Skip to content

gh-116541: Handle errors correctly in _pystatvfs_fromstructstatvfs #116542

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

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Mar 9, 2024

Comment on lines +12997 to +12998
SET_RESULT(PyLong_FromLong((long) st.f_bsize));
SET_RESULT(PyLong_FromLong((long) st.f_frsize));
Copy link
Member

Choose a reason for hiding this comment

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

It seems that some code is the same in both branches.

Also, on Linux some of fields are defined as unsigned long instead of long. Did not check other Posix systems. There may be a problem, but this is another issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I found this:

struct statvfs {
               unsigned long  f_bsize;    /* Filesystem block size */
               unsigned long  f_frsize;   /* Fragment size */
               fsblkcnt_t     f_blocks;   /* Size of fs in f_frsize units */
               fsblkcnt_t     f_bfree;    /* Number of free blocks */
               fsblkcnt_t     f_bavail;   /* Number of free blocks for
                                             unprivileged users */
               fsfilcnt_t     f_files;    /* Number of inodes */
               fsfilcnt_t     f_ffree;    /* Number of free inodes */
               fsfilcnt_t     f_favail;   /* Number of free inodes for
                                             unprivileged users */
               unsigned long  f_fsid;     /* Filesystem ID */
               unsigned long  f_flag;     /* Mount flags */
               unsigned long  f_namemax;  /* Maximum filename length */
           };

My proposal:

  • Let's keep this PR focused on a new error handling
  • I will open a new issue about this and do more research: why is it like this
  • Probably I will send a second PR fixing the type

Since posixmodule is rather hard, I would prefer not to do any semantic changes now.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

If you are going to backport this change, you can merge it first. Otherwise it is better to wait until the other issue be solved.

@sobolevn
Copy link
Member Author

I am going to backport this change, like all others. Thanks a lot for finding this and reviewing my PRs! 👍

Here's a link for the statvfs issue: #116642

@sobolevn sobolevn merged commit f8147d0 into python:main Mar 12, 2024
@miss-islington-app
Copy link

Thanks @sobolevn for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 12, 2024
@bedevere-app
Copy link

bedevere-app bot commented Mar 12, 2024

GH-116643 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Mar 12, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 12, 2024
@bedevere-app
Copy link

bedevere-app bot commented Mar 12, 2024

GH-116644 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Mar 12, 2024
sobolevn added a commit that referenced this pull request Mar 12, 2024
…atvfs` (GH-116542) (#116643)

gh-116541: Handle errors correctly in `_pystatvfs_fromstructstatvfs` (GH-116542)
(cherry picked from commit f8147d0)

Co-authored-by: Nikita Sobolev <[email protected]>
sobolevn added a commit that referenced this pull request Mar 12, 2024
…atvfs` (GH-116542) (#116644)

gh-116541: Handle errors correctly in `_pystatvfs_fromstructstatvfs` (GH-116542)
(cherry picked from commit f8147d0)

Co-authored-by: Nikita Sobolev <[email protected]>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
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.

2 participants