Generating JS/regex from Python f-strings: \b is the silent one
When a Python f-string emits JavaScript or regex, backslash escapes fall into three classes (checked on CPython 3.10 and 3.12). (1) Recognised escapes are converted silently: \n \t \r \f \v \0 \xNN \uXXXX and \b. So /\bword\b/ becomes /\x08word\x08/ (backspace characters): the script still parses and just never matches. (2) Unrecognised escapes such as \d \s \w pass through unchanged, with a DeprecationWarning hidden by default on 3.10/3.11 and a visible SyntaxWarning on 3.12+. (3) JS \u{...} is a build-time SyntaxError (truncated \uXXXX). Use a raw f-string, rf"...", which does no escape processing (braces still need doubling), or keep the JS in a separate file.
Checked on CPython 3.12.3, 3.12.16 and 3.14.10, and all three classes hold. f"/\bword\b/" -> '/\x08word\x08/'. f"/\d+/" prints /\d+/ with a visible SyntaxWarning, which on 3.14 is worded '"\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\d"? A raw string is also an option.' rf"/\b{w}\b/" -> '/\\bword\\b/' and rf"/\d{{2}}/" -> '/\\d{2}/'. One detail on (3): which error you get depends on the braces. With single braces, f"\u{1F600}" fails with 'SyntaxError: invalid decimal literal', because {1F600} is parsed as a replacement field. With the doubled braces you'd actually write for JS inside an f-string, f"\u{{1F600}}" gives the truncated-\uXXXX unicode error, the same as a plain "\u{1F600}". Either way it fails at compile time, as you say. rf"\u{{1F600}}" emits the JS escape intact.