diff mbox series

[v2,3/7] drivers/comedi: fix Python string escapes

Message ID 20230912060801.95533-4-bgray@linux.ibm.com (mailing list archive)
State New
Headers show
Series Fix Python string escapes | expand

Commit Message

Benjamin Gray Sept. 12, 2023, 6:07 a.m. UTC
Python 3.6 introduced a DeprecationWarning for invalid escape sequences.
This is upgraded to a SyntaxWarning in Python 3.12, and will eventually
be a syntax error.

Fix these now to get ahead of it before it's an error.

Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
---
 drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ian Abbott Sept. 12, 2023, 10:18 a.m. UTC | #1
On 12/09/2023 07:07, Benjamin Gray wrote:
> Python 3.6 introduced a DeprecationWarning for invalid escape sequences.
> This is upgraded to a SyntaxWarning in Python 3.12, and will eventually
> be a syntax error.
> 
> Fix these now to get ahead of it before it's an error.
> 
> Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
> ---
>   drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py b/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
> index 90378fb50580..d19101fc2a94 100755
> --- a/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
> +++ b/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
> @@ -44,7 +44,7 @@ def routedict_to_structinit_single(name, D, return_name=False):
>   
>       lines.append('\t\t[B({})] = {{'.format(D0_sig))
>       for D1_sig, value in D1:
> -      if not re.match('[VIU]\([^)]*\)', value):
> +      if not re.match(r'[VIU]\([^)]*\)', value):
>           sys.stderr.write('Invalid register format: {}\n'.format(repr(value)))
>           sys.stderr.write(
>             'Register values should be formatted with V(),I(),or U()\n')

Looks good thanks!  I ran the modified script using 'make everything' in 
the directory (after setting up a python venv to install ctypesgen) and 
it didn't break anything. (There were some harmless errors output by 
ctypesgen due to failing to parse some GCC extensions, but those are 
nothing to do with this patch and the generated C files are OK.)

Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
diff mbox series

Patch

diff --git a/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py b/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
index 90378fb50580..d19101fc2a94 100755
--- a/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
+++ b/drivers/comedi/drivers/ni_routing/tools/convert_csv_to_c.py
@@ -44,7 +44,7 @@  def routedict_to_structinit_single(name, D, return_name=False):
 
     lines.append('\t\t[B({})] = {{'.format(D0_sig))
     for D1_sig, value in D1:
-      if not re.match('[VIU]\([^)]*\)', value):
+      if not re.match(r'[VIU]\([^)]*\)', value):
         sys.stderr.write('Invalid register format: {}\n'.format(repr(value)))
         sys.stderr.write(
           'Register values should be formatted with V(),I(),or U()\n')