From c93f2624277bd0003adbaa7b0df73cd4d457064d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 6 May 2022 22:46:01 -0700 Subject: [PATCH] Add closure argument to exec() (#7793) python/cpython#92204 --- stdlib/builtins.pyi | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 052e84219..568c8931f 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1150,9 +1150,22 @@ def eval( ) -> Any: ... # Comment above regarding `eval` applies to `exec` as well -def exec( - __source: str | ReadableBuffer | CodeType, __globals: dict[str, Any] | None = ..., __locals: Mapping[str, object] | None = ... -) -> None: ... +if sys.version_info >= (3, 11): + def exec( + __source: str | ReadableBuffer | CodeType, + __globals: dict[str, Any] | None = ..., + __locals: Mapping[str, object] | None = ..., + *, + closure: tuple[_Cell, ...] | None = ..., + ) -> None: ... + +else: + def exec( + __source: str | ReadableBuffer | CodeType, + __globals: dict[str, Any] | None = ..., + __locals: Mapping[str, object] | None = ..., + ) -> None: ... + def exit(code: object = ...) -> NoReturn: ... class filter(Iterator[_T], Generic[_T]):