[Python-Dev] Is this safe enough? Re: [Python-checkins] cpython: _Py_Identifier are always ASCII strings (original) (raw)

Jim Jewett jimjjewett at gmail.com
Mon Feb 6 17:28:40 CET 2012


I realize that _Py_Identifier is a private name, and that PEP 3131 requires anything (except test cases) in the standard library to stick with ASCII ... but somehow, that feels like too long of a chain.

I would prefer to see _Py_Identifier renamed to _Py_ASCII_Identifier, or at least a comment stating that Identifiers will (per PEP 3131) always be ASCII -- preferably with an assert to back that up.

-jJ

On Sat, Feb 4, 2012 at 7:46 PM, victor.stinner <python-checkins at python.org> wrote:

http://hg.python.org/cpython/rev/d2c1521ad0a1 changeset:   74772:d2c1521ad0a1 user:        Victor Stinner <victor.stinner at haypocalc.com> date:        Sun Feb 05 01:45:45 2012 +0100 summary:  PyIdentifier are always ASCII strings

files:  Objects/unicodeobject.c |  5 ++---  1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1744,9 +1744,8 @@  PyUnicodeFromId(PyIdentifier *id)  { if (!id->object) { -        id->object = PyUnicodeDecodeUTF8Stateful(id->string, -                                                  strlen(id->string), -                                                  NULL, NULL); +        id->object = unicodefromascii((unsigned char*)id->string, +                                       strlen(id->string)); if (!id->object) return NULL; PyUnicodeInternInPlace(&id->object); -- Repository URL: http://hg.python.org/cpython



More information about the Python-Dev mailing list