Skip to content

os.PIDFD_NONBLOCK is missing, yet according to documentation it should be present #127583

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

Closed
n6koma7a opened this issue Dec 3, 2024 · 3 comments
Labels
easy extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@n6koma7a
Copy link

n6koma7a commented Dec 3, 2024

Bug report

Bug description:

# Add a code block here, if required
import os
os.PIDFD_NONBLOCK

https://docs.python.org/3/library/os.html#os.PIDFD_NONBLOCK

python3.13 Wed 04 Dec 2024 01:57:39 AM +03
Python 3.13.0 (main, Oct 8 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.

import os
os.PIDFD_NONBLOCK
Traceback (most recent call last):
File "", line 1, in
os.PIDFD_NONBLOCK
AttributeError: module 'os' has no attribute 'PIDFD_NONBLOCK'. Did you mean: 'EFD_NONBLOCK'?

CPython versions tested on:

3.13

Operating systems tested on:

Linux

@n6koma7a n6koma7a added the type-bug An unexpected behavior, bug, or error label Dec 3, 2024
@JelleZijlstra
Copy link
Member

The docs say the constant is available on Linux >= 5.10.

However, I can replicate this on a Linux system running kernel 5.15 using current main:

$ uname -a
Linux devshared41 5.15.0-1070-aws #76~20.04.1-Ubuntu SMP Mon Sep 2 12:20:36 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ ./python -c 'import os; print(hasattr(os, "PIDFD_NONBLOCK"))'
False

The code looks correct:

#ifdef PIDFD_NONBLOCK

And manpages confirm the constant should exist: https://man7.org/linux/man-pages/man2/pidfd_open.2.html

Maybe we're missing an #include?

cc @kumaraditya303 who added this in #93313

@stephen-hansen
Copy link
Contributor

just browsing through here, looks like relevant kernel thread: https://lore.kernel.org/all/ZkrZb91EgZoaOybZ@t420/T/

Seems like the missing #include is on <linux/pidfd.h>.

@picnixz picnixz added extension-modules C modules in the Modules dir easy labels Dec 5, 2024
@kumaraditya303
Copy link
Contributor

Fixed by #127593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants