[Python-Dev] PEP-393: request for keeping PyUnicode_EncodeDecimal() (original) (raw)
Stefan Krah stefan at bytereef.org
Sun Oct 2 13:04:16 CEST 2011
- Previous message: [Python-Dev] PEP-393: request for keeping PyUnicode_EncodeDecimal()
- Next message: [Python-Dev] PEP-393: request for keeping PyUnicode_EncodeDecimal()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Martin v. Löwis" <martin at v.loewis.de> wrote:
> longobject.c still used PyUnicodeEncodeDecimal() until 10 months > ago (8304bd765bcf). I missed the PyUnicodeTransformDecimalToASCII() > commit, probably because #10557 is still open. > > That's why I wouldn't like to implement the function myself at least > until the API is settled.
I don't understand. If you implement it yourself, you don't have to worry at all what the API is.
What I'm looking for is a public function that is silently updated if python-dev decides to accept other numerical input. As I understand from your comments below, PyUnicode_EncodeDecimal() is frozen, so that function does indeed not help.
I would consider it reasonable for PyUnicode_TransformDecimalAndSpaceToASCII() to be documented as:
"This function might accept different numerical input in the future."
The reason is that some people would like to accept additional input (see #6632), while others would like to restrict input. If there is a function that will always track whatever will be decided, extension authors don't have to worry about being up-to-date.
out = malloc(PyUnicodeGETLENGTH(in)+1); for (i = 0; i < PyUnicodeGETLENGTH(in); i++) { PyUCS4 ch = PyUnicodeREADCHAR(in, i); int d = PyUNICODETODIGIT(ch); if (d != -1) { out[i] == '0'+d; continue; } if (ch < 128) out[i] = ch; else { error(); return; } } out[i] = '\0';
Thanks for that. I think alternative leading and trailing whitespace would need to be handled as well: Decimal("\u180E1.233").
> Will PyUnicodeTransformDecimalAndSpaceToASCII() be public?
It's already included in 3.2, so it can't be removed that easily. I wish it had been private, though - we have way too many API functions dealing with Unicode.
I can find PyUnicode_TransformDecimalToASCII() in 3.2, but not PyUnicode_TransformDecimalAndSpaceToASCII().
Stefan Krah
- Previous message: [Python-Dev] PEP-393: request for keeping PyUnicode_EncodeDecimal()
- Next message: [Python-Dev] PEP-393: request for keeping PyUnicode_EncodeDecimal()
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]