edgewall / genshi

Python toolkit for generation of output for the web
http://genshi.edgewall.org
Other
86 stars 35 forks source link

PyUnicode_FromUnicode is deprecated #25

Closed methane closed 3 years ago

methane commented 4 years ago

It is deprecated by PEP 393.

My recommendation is:

  1. Encode the text to UTF-8 (PyUnicode_AsUTF8AndSize).
  2. Escape it into raw buffer
  3. Decode it (PyUnicode_FromStringAndSize).

While PEP 393 specific API can be faster, it is CPython only, and it will be broken if CPython changed string implementation again. So I recommend UTF-8 APIs.

FelixSchwarz commented 4 years ago

Good point - I think that's exactly the reasoning of cef2c8df44166195e1705638f9f17033a4943bb7 (pure python version for Python >= 3.3).

methane commented 4 years ago

I didn't notice that because I just grepped sdist packages in PyPI.