mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
Issue #5828 (Invalid behavior of unicode.lower): Fixed bogus logic in
makeunicodedata.py and regenerated the Unicode database (This fixes u'\u1d79'.lower() == '\x00').
This commit is contained in:
parent
140d9d673e
commit
5d98ec76bb
4 changed files with 41 additions and 25 deletions
|
@ -371,33 +371,32 @@ def makeunicodetype(unicode, trace):
|
|||
flags |= UPPER_MASK
|
||||
# use delta predictor for upper/lower/title if it fits
|
||||
if record[12]:
|
||||
upper = int(record[12], 16) - char
|
||||
if -32768 <= upper <= 32767 and delta:
|
||||
upper = upper & 0xffff
|
||||
else:
|
||||
upper += char
|
||||
delta = False
|
||||
upper = int(record[12], 16)
|
||||
else:
|
||||
upper = 0
|
||||
upper = char
|
||||
if record[13]:
|
||||
lower = int(record[13], 16) - char
|
||||
if -32768 <= lower <= 32767 and delta:
|
||||
lower = lower & 0xffff
|
||||
else:
|
||||
lower += char
|
||||
delta = False
|
||||
lower = int(record[13], 16)
|
||||
else:
|
||||
lower = 0
|
||||
lower = char
|
||||
if record[14]:
|
||||
title = int(record[14], 16) - char
|
||||
if -32768 <= lower <= 32767 and delta:
|
||||
title = title & 0xffff
|
||||
else:
|
||||
title += char
|
||||
delta = False
|
||||
title = int(record[14], 16)
|
||||
else:
|
||||
# UCD.html says that a missing title char means that
|
||||
# it defaults to the uppercase character, not to the
|
||||
# character itself. Apparently, in the current UCD (5.x)
|
||||
# this feature is never used
|
||||
title = upper
|
||||
upper_d = upper - char
|
||||
lower_d = lower - char
|
||||
title_d = title - char
|
||||
if -32768 <= upper_d <= 32767 and \
|
||||
-32768 <= lower_d <= 32767 and \
|
||||
-32768 <= title_d <= 32767:
|
||||
# use deltas
|
||||
upper = upper_d & 0xffff
|
||||
lower = lower_d & 0xffff
|
||||
title = title_d & 0xffff
|
||||
else:
|
||||
title = 0
|
||||
if not delta:
|
||||
flags |= NODELTA_MASK
|
||||
# decimal digit, integer digit
|
||||
decimal = 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue