From b1d51f49b73e8e4bc6ef77ddd3af35dd2d872d15 Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Thu, 28 Sep 2023 14:09:39 +0200 Subject: [PATCH 1/3] Fix resource.prlimit for Python 3.12+ --- stdlib/resource.pyi | 5 +---- tests/stubtest_allowlists/linux-py312.txt | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/stdlib/resource.pyi b/stdlib/resource.pyi index f2e979ff89af..821ab9f7a36f 100644 --- a/stdlib/resource.pyi +++ b/stdlib/resource.pyi @@ -86,8 +86,5 @@ if sys.platform != "win32": def getrusage(__who: int) -> struct_rusage: ... def setrlimit(__resource: int, __limits: tuple[int, int]) -> None: ... if sys.platform == "linux": - @overload - def prlimit(pid: int, resource: int, limits: tuple[int, int]) -> tuple[int, int]: ... - @overload - def prlimit(pid: int, resource: int) -> tuple[int, int]: ... + def prlimit(__pid: int, __resource: int, __limits: tuple[int, int] | None = ...) -> tuple[int, int]: ... error = OSError diff --git a/tests/stubtest_allowlists/linux-py312.txt b/tests/stubtest_allowlists/linux-py312.txt index 7463b5ea289c..e73f41155570 100644 --- a/tests/stubtest_allowlists/linux-py312.txt +++ b/tests/stubtest_allowlists/linux-py312.txt @@ -1,6 +1,5 @@ _?curses.color_pair _posixsubprocess.fork_exec -resource.prlimit signal.sigtimedwait signal.sigwaitinfo xxlimited.Xxo.x_exports From 528240273edd67e7d484b175fd7a27e1be1340f1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:11:12 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/resource.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/resource.pyi b/stdlib/resource.pyi index 821ab9f7a36f..277312d7d5bc 100644 --- a/stdlib/resource.pyi +++ b/stdlib/resource.pyi @@ -1,6 +1,5 @@ import sys from _typeshed import structseq -from typing import overload from typing_extensions import Final, final if sys.platform != "win32": From f7764be97356b2175c03f8f1980f49b2be4c310c Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Thu, 28 Sep 2023 14:43:18 +0200 Subject: [PATCH 3/3] Update stdlib/resource.pyi Co-authored-by: Alex Waygood --- stdlib/resource.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/resource.pyi b/stdlib/resource.pyi index 277312d7d5bc..57cefb4681ac 100644 --- a/stdlib/resource.pyi +++ b/stdlib/resource.pyi @@ -85,5 +85,8 @@ if sys.platform != "win32": def getrusage(__who: int) -> struct_rusage: ... def setrlimit(__resource: int, __limits: tuple[int, int]) -> None: ... if sys.platform == "linux": - def prlimit(__pid: int, __resource: int, __limits: tuple[int, int] | None = ...) -> tuple[int, int]: ... + if sys.version_info >= (3, 12): + def prlimit(__pid: int, __resource: int, __limits: tuple[int, int] | None = None) -> tuple[int, int]: ... + else: + def prlimit(__pid: int, __resource: int, __limits: tuple[int, int] = ...) -> tuple[int, int]: ... error = OSError