Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
serge-sans-paille opened this issue Feb 5, 2025 · 1 comment

Comments

@serge-sans-paille
Copy link
Contributor

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

@hynek
Copy link
Member

hynek commented Feb 6, 2025

Thanks, but this is out of scope. I've added a warning in 5820ce7, though.

@hynek hynek closed this as completed Feb 6, 2025
serge-sans-paille added a commit to serge-sans-paille/attrs that referenced this issue Feb 8, 2025
github-merge-queue bot pushed a commit that referenced this issue Feb 9, 2025
)

* Accept valid unicode identifiers as class parameter to make_class

Related to #1404

* Test code style

* Add changelog

---------

Co-authored-by: Hynek Schlawack <hs@ox.cx>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants