◐ Shell
clean mode source ↗

Type name cannot contain surrogates

Issue caught after an update to test_builtins in #4765. Creating a new type and supplying as a name a value that contains a surrogate (in this case \udcdc is used) should result in an error.

RustPython:

>>> type("A\udcdcB", (), {})
>>> <class '__main__.A�B'>

While in CPython:

>>> type("A\udcdcB", (), {})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcdc' in position 1: surrogates not allowed