Skip to content

Valid Unicode identifier can't be used as attrs.make_class parameter #1404

@serge-sans-paille

Description

@serge-sans-paille

Simple reproducer:

>>> import attrs
>>> clsname = '䆊ㅁ'
>>> attrs/make_class(clsname, [])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.12/site-packages/attr/_make.py", line 3042, in make_class
    return _attrs(these=cls_dict, **attributes_arguments)(type_)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/attr/_make.py", line 1619, in wrap
    builder = _ClassBuilder(
              ^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/attr/_make.py", line 724, in __init__
    attrs, base_attrs, base_map = _transform_attrs(
                                  ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/attr/_make.py", line 598, in _transform_attrs
    AttrsClass = _make_attr_tuple_class(cls.__name__, attr_names)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/attr/_make.py", line 374, in _make_attr_tuple_class
    return globs[attr_class_name]
           ~~~~~^^^^^^^^^^^^^^^^^
KeyError: '䆊ㅁAttributes'

This was raised by fuzzing when setting up google/oss-fuzz#13009

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions