Skip to content

Support frozendict in various builtins #145118

Description

@rhettinger

The type, str.maketrans, and bytes.maketrans builtins should support frozendict. The issues with exec and eval were reported in a separate issue.

>>>type("MyClass", (), {"x": 10})
<class'__main__.MyClass'>>>>type("MyClass", (), frozendict({"x": 10}))
Traceback (mostrecentcalllast):
File"<pyshell#30>", line1, in<module>MyClass=type("MyClass", (), frozendict({"x": 10}))
TypeError: type.__new__() argument3mustbedict, notfrozendict>>>str.maketrans(dict({'a': 'A'}))
{97: 'A'}
>>>str.maketrans(frozendict({'a': 'A'}))
Traceback (mostrecentcalllast):
File"<pyshell#23>", line1, in<module>str.maketrans(frozendict({'a': 'A'}))
TypeError: ifyougiveonlyoneargumenttomaketransitmustbeadict

Linked PRs

Metadata

Metadata

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions