Skip to content

SystemError when builtins is not a dict + eval #112716

Closed
@JelleZijlstra

Description

@JelleZijlstra

Bug report

Bug description:

If __builtins__ is not a dict, you can get a SystemError:

>>> import types
>>> exec("import builtins; builtins.print(3)", {"__builtins__": types.MappingProxyType({})})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    exec("import builtins; builtins.print(3)", {"__builtins__": types.MappingProxyType({})})
  File "<string>", line 1, in <module>
SystemError: Objects/dictobject.c:1761: bad argument to internal function

Originally found this while playing with https://oskaerik.github.io/theevalgame/

CPython versions tested on:

3.11, CPython main branch

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Labels

3.11only security fixes3.12only security fixes3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions