kovidgoyal/kitty · error · ValueError

{x} is not a unicode codepoint of the form U+number

Error message

{x} is not a unicode codepoint of the form U+number

What it means

Each codepoint in a symbol_map range must start with 'U+' followed by hexadecimal digits; to_chr rejects anything else with this message.

Source

Thrown at kitty/options/utils.py:1225

    parts = val.split(maxsplit=1)
    if len(parts) > 1:
        alias_name, rest = parts
        yield alias_name, rest


kitten_alias = action_alias


def symbol_map_parser(val: str, min_size: int = 2) -> Iterable[tuple[tuple[int, int], str]]:
    parts = val.split()

    if len(parts) < min_size:
        raise ValueError('must have codepoints AND font name')
    family = ' '.join(parts[1:])

    def to_chr(x: str) -> int:
        if not x.startswith('U+'):
            raise ValueError(f'{x} is not a unicode codepoint of the form U+number')
        return int(x[2:], 16)

    for x in parts[0].split(','):
        a_, b_ = x.replace('–', '-').partition('-')[::2]
        b_ = b_ or a_
        a, b = map(to_chr, (a_, b_))
        if b < a or max(a, b) > sys.maxunicode or min(a, b) < 1:
            raise ValueError(f'Invalid range: {a:x} - {b:x}')
        yield (a, b), family


def symbol_map(val: str) -> Iterable[tuple[tuple[int, int], str]]:
    yield from symbol_map_parser(val)


def narrow_symbols(val: str) -> Iterable[tuple[tuple[int, int], int]]:
    for x, y in symbol_map_parser(val, min_size=1):
        yield x, int(y or 1)

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Write codepoints as U+hex, e.g. U+E0A0
  2. Fix any malformed endpoints in ranges (both sides of the dash)

Example fix

# before
symbol_map 0xE0A0 Nerd Font
# after
symbol_map U+E0A0 Nerd Font
Defensive patterns

Strategy: validation

Validate before calling

import re
def valid_codepoints(spec: str) -> bool:
    return all(re.fullmatch(r'[0-9a-fA-F]+', p[2:]) for x in spec.split(',') for p in x.replace('\u2013','-').partition('-')[::2] if p.startswith('U+'))

Prevention

When it happens

Trigger: Codepoints written as 'e0a0', '0xE0A0', 'U+E0A0-U+E0A2' with a malformed endpoint, or non-hex characters after U+.

Common situations: Copy/pasting font docs that use 0x... notation, typos like U+E0AG, or en-dash ranges where one side is empty.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/cf6af63945cdd58b. Report an issue: GitHub.