(s, pos, digits, message, errors)
| 1466 | |
| 1467 | |
| 1468 | def hexescape(s, pos, digits, message, errors): |
| 1469 | ch = 0 |
| 1470 | p = [] |
| 1471 | number_end = hex_number_end(s, pos, digits) |
| 1472 | if number_end - pos != digits: |
| 1473 | x = unicode_call_errorhandler( |
| 1474 | errors, "unicodeescape", message, s, pos - 2, number_end |
| 1475 | ) |
| 1476 | p.append(x[0]) |
| 1477 | pos = x[1] |
| 1478 | else: |
| 1479 | ch = int(s[pos : pos + digits], 16) |
| 1480 | # /* when we get here, ch is a 32-bit unicode character */ |
| 1481 | if ch <= sys.maxunicode: |
| 1482 | p.append(chr(ch)) |
| 1483 | pos += digits |
| 1484 | |
| 1485 | elif ch <= 0x10FFFF: |
| 1486 | ch -= 0x10000 |
| 1487 | p.append(chr(0xD800 + (ch >> 10))) |
| 1488 | p.append(chr(0xDC00 + (ch & 0x03FF))) |
| 1489 | pos += digits |
| 1490 | else: |
| 1491 | message = "illegal Unicode character" |
| 1492 | x = unicode_call_errorhandler( |
| 1493 | errors, "unicodeescape", message, s, pos - 2, pos + digits |
| 1494 | ) |
| 1495 | p.append(x[0]) |
| 1496 | pos = x[1] |
| 1497 | res = p |
| 1498 | return res, pos |
| 1499 | |
| 1500 | |
| 1501 | def PyUnicode_DecodeUnicodeEscape(s, size, errors, final): |
no test coverage detected