Skip to content

Type name cannot contain surrogates #4786

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

Open
DimitrisJim opened this issue Mar 27, 2023 · 2 comments
Open

Type name cannot contain surrogates #4786

DimitrisJim opened this issue Mar 27, 2023 · 2 comments
Labels
C-bug Something isn't working C-compat A discrepancy between RustPython and CPython

Comments

@DimitrisJim
Copy link
Member

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
@DimitrisJim DimitrisJim added C-bug Something isn't working C-compat A discrepancy between RustPython and CPython labels Mar 27, 2023
@youknowone
Copy link
Member

depending on non-utf8 string support

@JazzGlobal
Copy link
Contributor

JazzGlobal commented May 1, 2023

Rust noob here. Is this discrepancy caused by how Rust handles char and String versus a language like C#?

EDIT: My reasoning for the above question is due to Rust supporting things like 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working C-compat A discrepancy between RustPython and CPython
Projects
None yet
Development

No branches or pull requests

3 participants