Skip to content

Commit c93f262

Browse files
Add closure argument to exec() (#7793)
python/cpython#92204
1 parent e8b3619 commit c93f262

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

stdlib/builtins.pyi

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,9 +1150,22 @@ def eval(
11501150
) -> Any: ...
11511151

11521152
# Comment above regarding `eval` applies to `exec` as well
1153-
def exec(
1154-
__source: str | ReadableBuffer | CodeType, __globals: dict[str, Any] | None = ..., __locals: Mapping[str, object] | None = ...
1155-
) -> None: ...
1153+
if sys.version_info >= (3, 11):
1154+
def exec(
1155+
__source: str | ReadableBuffer | CodeType,
1156+
__globals: dict[str, Any] | None = ...,
1157+
__locals: Mapping[str, object] | None = ...,
1158+
*,
1159+
closure: tuple[_Cell, ...] | None = ...,
1160+
) -> None: ...
1161+
1162+
else:
1163+
def exec(
1164+
__source: str | ReadableBuffer | CodeType,
1165+
__globals: dict[str, Any] | None = ...,
1166+
__locals: Mapping[str, object] | None = ...,
1167+
) -> None: ...
1168+
11561169
def exit(code: object = ...) -> NoReturn: ...
11571170

11581171
class filter(Iterator[_T], Generic[_T]):

0 commit comments

Comments
 (0)