New submission from Eric V. Smith <e...@trueblade.com>:

See issue 33880 for the same issue with namedtuple.

This shows up on dataclasses only through make_dataclass. This is an expected 
ValueError:

>>> make_dataclass('a', ['a', 'b', 'c', 'a'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File 
"/cygdrive/c/home/eric/.local/lib/python3.6/site-packages/dataclasses.py", line 
1123, in make_dataclass
    raise TypeError(f'Field name duplicated: {name!r}')
TypeError: Field name duplicated: 'a'

But this is a SyntaxError:

>>> make_dataclass('a', ['\u00b5', '\u03bc'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File 
"/cygdrive/c/home/eric/.local/lib/python3.6/site-packages/dataclasses.py", line 
1133, in make_dataclass
    unsafe_hash=unsafe_hash, frozen=frozen)
  File 
"/cygdrive/c/home/eric/.local/lib/python3.6/site-packages/dataclasses.py", line 
958, in dataclass
    return wrap(_cls)
  File 
"/cygdrive/c/home/eric/.local/lib/python3.6/site-packages/dataclasses.py", line 
950, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
  File 
"/cygdrive/c/home/eric/.local/lib/python3.6/site-packages/dataclasses.py", line 
871, in _process_class
    else 'self',
  File 
"/cygdrive/c/home/eric/.local/lib/python3.6/site-packages/dataclasses.py", line 
490, in _init_fn
    return_type=None)
  File 
"/cygdrive/c/home/eric/.local/lib/python3.6/site-packages/dataclasses.py", line 
356, in _create_fn
    exec(txt, globals, locals)
  File "<string>", line 1
SyntaxError: duplicate argument 'μ' in function definition

----------
assignee: eric.smith
components: Library (Lib)
messages: 319766
nosy: eric.smith
priority: low
severity: normal
status: open
title: dataclasses should use NFKD to find duplicate members
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33881>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to