Skip to content
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

Py_UNICODE is deprecated #54

Open
methane opened this issue Jun 15, 2020 · 5 comments
Open

Py_UNICODE is deprecated #54

methane opened this issue Jun 15, 2020 · 5 comments

Comments

@methane
Copy link

methane commented Jun 15, 2020

Py_UNICODE is deprecated since Python 3.3, and we are planning to remove them in Python 3.11.
Py_UNICODE is deprecated since Python 3.3 and will be removed in Python 3.11.
Would you replace Py_UNICODE with wchar_t, and PyUnicode_FromUnicode with PyUnicode_FromWideChar?

./python-Levenshtein-0.12.0/Levenshtein/_levenshtein.c:1001:      result = PyUnicode_FromUnicode(medstr, len);
./python-Levenshtein-0.12.0/Levenshtein/_levenshtein.c:1088:      result = PyUnicode_FromUnicode(medstr, len);
./python-Levenshtein-0.12.0/Levenshtein/_levenshtein.c:1930:      result = PyUnicode_FromUnicode(s, len);
./python-Levenshtein-0.12.0/Levenshtein/_levenshtein.c:1946:      result = PyUnicode_FromUnicode(s, len);
@maxbachmann
Copy link

maxbachmann commented Jan 17, 2022

Is PyUnicode_FromUnicode actually removed in Python 3.11? The Python docs lists the removal for Python 3.12.

@methane
Copy link
Author

methane commented Jan 17, 2022

The removal is postponed to Python 3.12.
But PyUnicode_FromUnicode() emits runtime warning. So it is very inefficient already.

@maxbachmann
Copy link

Good to know. I will replace it in my fork in the next release.

@maxbachmann
Copy link

@methane does PyUnicode_AS_UNICODE emit a warning as well? This API is significantly harder to replace, since there is no 1:1 replacement (either needs to handle 1/2/4 Byte sizes or allocate + deallocate).

@methane
Copy link
Author

methane commented Jan 17, 2022

Use PyUnicode_AsUCS4Copy() and PyMem_Free().
PyUnicode_AS_UNICODE() uses UTF-16 on Windows. I think it is bad for levenshtein library.

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