Skip to content

Enable os.getrandom with modern Linux UAPI headers - #1183

Merged
jjhelmus merged 2 commits into
mainfrom
jjh/weak_sym_getrandom
Jul 22, 2026
Merged

jjhelmus merged 2 commits into
mainfrom
jjh/weak_sym_getrandom

Conversation

@jjhelmus

Copy link
Copy Markdown
Contributor

Enable os.getrandom when building CPython against the modern Linux UAPI headers.

Older glibc versions do not define SYS_getrandom which is used for the os.getrandom implementation. Patch CPython to use __NR_getrandom which is defined in the UAPI headers. This make os.getrandom available in all builds.

This does not increase the minimum required glibc or runtime kernel version. If the running kernel does not support getrandom, the syscall returns ENOSYS, which Python exposes as OSError.

Related to #193.

jjhelmus added 2 commits July 21, 2026 10:22
Use the __NR_getrandom syscall from the Linux UAPI headers as older
glibc version do not define SYS_getrandom.
@jjhelmus jjhelmus added platform:linux Specific to the Linux platform python:all Select all Python versions arch:all Select all architectures build:all labels Jul 21, 2026
@jjhelmus
jjhelmus requested a review from EliteTK July 21, 2026 16:09
@jjhelmus
jjhelmus merged commit dd3980d into main Jul 22, 2026
448 checks passed
@jjhelmus
jjhelmus deleted the jjh/weak_sym_getrandom branch July 22, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch:all Select all architectures build:all platform:linux Specific to the Linux platform python:all Select all Python versions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants