Message145254
Here is a new patch that stores the names of aliases and named sequences in the Private Use Area.
To summarize a bit, this is what we want:
| 6.0.0 | 3.2.0 |
--------+-------+-------+
\N{...} | A | - |
.name | - | - |
.lookup | A,NS | - |
I.e., \N{...} should only support aliases, unicodedata.lookup should support aliases and named sequences, unicodedata.name doesn't support either, and when 3.2.0 is used nothing is supported.
The function calls involved for these 3 functions are:
\N{...} and .lookup:
_getcode
_cmpname
_getucname
_check_alias
.name:
_getucname
My patch adds an extra arg to _getcode and _getucname (I hope that's fine -- or are they public?).
_getcode is called by \N{...} and .lookup; both support aliases, so _getcode now resolves aliases by default. Since only .lookup wants named sequences, _getcode now accepts an extra 'with_named_seq' arg and looks up named sequences only when its value is 1. .lookup passes 1, gets the codepoint, and converts it to a sequence. \N{...} passes 0 and doesn't get named sequences.
_getucname is called by .name and indirectly (through _cmpname) by .lookup and \N{...}. Since _getcode takes care of deciding who gets aliases and sequences, _getucname now accepts an extra 'with_alias_and_seq' arg and looks up aliases and named sequences only when its value is 1. _cmpname passes 1, gets aliases and named sequences and then lets _getcode decide what to do with them. .name passes 0 and doesn't get aliases and named sequences.
All this happens on 6.0.0 only, when self != NULL (i.e. we are using 3.2.0) named sequences and aliases are ignored.
The patch doesn't include the changes to unicodename_db.h -- run makeunicodedata.py to get them.
I also added more tests to make sure that the names added in the PUA don't leak, and that ucd_3_2_0 is not affected. |
|
Date |
User |
Action |
Args |
2011-10-09 13:21:00 | ezio.melotti | set | recipients:
+ ezio.melotti, lemburg, gvanrossum, loewis, terry.reedy, mrabarnett, tchrist |
2011-10-09 13:20:59 | ezio.melotti | set | messageid: <1318166459.35.0.821972995683.issue12753@psf.upfronthosting.co.za> |
2011-10-09 13:20:58 | ezio.melotti | link | issue12753 messages |
2011-10-09 13:20:58 | ezio.melotti | create | |
|