Skip to contentSkip to conversation

scripts/feature_to_c.py: fix invalid escape

RFC PATCH New Alex Bennée 1 participant 1 message Aug 12

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 scripts/feature_to_c.py: fix invalid escape

This leg of the python code is trying to emit literal octal values but bodges the escape sequence. The newer python on my macOS box complained:

/Users/alex/lsrc/qemu.git/gdbstub/../scripts/feature_to_c.py:28: SyntaxWarning: "\{" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\{"? A raw string is also an option.

    sys.stdout.write(f'\{c:03o}')
---
 scripts/feature_to_c.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/feature_to_c.py +1 -1
index a52cd2e9ec6..4275b758172 100644
@@ -25,7 +25,7 @@ def writeliteral(indent, bytes):
         elif c >= 32 and c < 127:
             sys.stdout.write(c.to_bytes(1, 'big').decode())
         else:
-            sys.stdout.write(f'\{c:03o}')
+            sys.stdout.write(f'\\{c:03o}')
 
     if quoted:
         sys.stdout.write('"')
Signature · 1 line
2.47.3