Great, thanks.  I saw a few bugs playing around a bit more:

1) Consecutive escape codes not fontified:
b'\x12\x23'  # Here only "\x12" would be fontified
2) Multi-line bytes literals fontified as string literals:
b'''\x12 \777 \1\23 \u1234'''  # Here '\u1234" would be (incorrectly) fontified
3) Octal escape codes may be one to three characters instead of always three (https://docs.python.org/3/reference/lexical_analysis.html#escape-sequences):
"\1 \12 \123"  # Here only "\123" would be fontified

I've attached a patch which fixes the above and adds a new test.  The new test (tests different combinations of multi-line literals) makes up the majority of the diff.

Thanks, Laurence

On Sat, Aug 6, 2022 at 2:02 PM Lars Ingebrigtsen <larsi@gnus.org> wrote:
Laurence Warne <laurencewarne@gmail.com> writes:

> Hi, this patch implements escape code syntax highlighting within string an bytes
> literals for python-mode (described at
> https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals)
> similar to how they are highlighted by https://pygments.org.

Thanks; pushed to Emacs 29.