Skip to content

Commit bb267c8

Browse files
authored
builtins: eval and exec can take globals and locals via keyword (#11934)
1 parent 4c6f295 commit bb267c8

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

stdlib/builtins.pyi

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,12 +1321,34 @@ def divmod(x: _T_contra, y: SupportsRDivMod[_T_contra, _T_co], /) -> _T_co: ...
13211321

13221322
# The `globals` argument to `eval` has to be `dict[str, Any]` rather than `dict[str, object]` due to invariance.
13231323
# (The `globals` argument has to be a "real dict", rather than any old mapping, unlike the `locals` argument.)
1324-
def eval(
1325-
source: str | ReadableBuffer | CodeType, globals: dict[str, Any] | None = None, locals: Mapping[str, object] | None = None, /
1326-
) -> Any: ...
1324+
if sys.version_info >= (3, 13):
1325+
def eval(
1326+
source: str | ReadableBuffer | CodeType,
1327+
/,
1328+
globals: dict[str, Any] | None = None,
1329+
locals: Mapping[str, object] | None = None,
1330+
) -> Any: ...
1331+
1332+
else:
1333+
def eval(
1334+
source: str | ReadableBuffer | CodeType,
1335+
globals: dict[str, Any] | None = None,
1336+
locals: Mapping[str, object] | None = None,
1337+
/,
1338+
) -> Any: ...
13271339

13281340
# Comment above regarding `eval` applies to `exec` as well
1329-
if sys.version_info >= (3, 11):
1341+
if sys.version_info >= (3, 13):
1342+
def exec(
1343+
source: str | ReadableBuffer | CodeType,
1344+
/,
1345+
globals: dict[str, Any] | None = None,
1346+
locals: Mapping[str, object] | None = None,
1347+
*,
1348+
closure: tuple[CellType, ...] | None = None,
1349+
) -> None: ...
1350+
1351+
elif sys.version_info >= (3, 11):
13301352
def exec(
13311353
source: str | ReadableBuffer | CodeType,
13321354
globals: dict[str, Any] | None = None,

0 commit comments

Comments
 (0)