Skip to content

dataclasses should use ast instead of generating code as strings #93452

Closed as not planned
@KOLANICH

Description

@KOLANICH

Feature or enhancement

It uses dynamic code generation and executing of it, but the code itself is generated as a string.

Pitch
May bring the following benefits:

  • performance and overhead: no need to parse the code onto AST
  • readability and modularity - ast is manipulated as objects
  • security - ast classes ctors can be made verifying that the strings used as names don't contain any chars unallowed in the and are not the same as keywords, this way reducing the possibilities to inject malicious code when the names are supplied from untrusted source.

Metadata

Metadata

Assignees

Labels

3.12only security fixesperformancePerformance or resource usagestdlibPython modules in the Lib dirtype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions