[libcamera-devel] utils: ipc: mojom_libcamera_generator.py: Fix Python warning
diff mbox series

Message ID 20240105131621.586786-1-mzamazal@redhat.com
State Accepted
Commit 3d45b9ad9aefd4b1e702f89febe4aa6e6d3e2b9c
Headers show
Series
  • [libcamera-devel] utils: ipc: mojom_libcamera_generator.py: Fix Python warning
Related show

Commit Message

Milan Zamazal Jan. 5, 2024, 1:16 p.m. UTC
Python 3.12 starts emitting the following warning when building libcamera:

  .../utils/ipc/generators/mojom_libcamera_generator.py:372:
  SyntaxWarning: invalid escape sequence '\.'
    if not re.match('^ipa\.[0-9A-Za-z_]+', namespace):

`r' prefix is now required before the regexp.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 utils/ipc/generators/mojom_libcamera_generator.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kieran Bingham Jan. 9, 2024, 12:44 p.m. UTC | #1
Quoting Milan Zamazal via libcamera-devel (2024-01-05 13:16:21)
> Python 3.12 starts emitting the following warning when building libcamera:
> 
>   .../utils/ipc/generators/mojom_libcamera_generator.py:372:
>   SyntaxWarning: invalid escape sequence '\.'
>     if not re.match('^ipa\.[0-9A-Za-z_]+', namespace):
> 
> `r' prefix is now required before the regexp.
> 
> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
> ---
>  utils/ipc/generators/mojom_libcamera_generator.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/ipc/generators/mojom_libcamera_generator.py b/utils/ipc/generators/mojom_libcamera_generator.py
> index 1a629f9d..582818c9 100644
> --- a/utils/ipc/generators/mojom_libcamera_generator.py
> +++ b/utils/ipc/generators/mojom_libcamera_generator.py
> @@ -369,7 +369,7 @@ def ValidateNamespace(namespace):
>      if namespace == '':
>          raise Exception('Must have a namespace')
>  
> -    if not re.match('^ipa\.[0-9A-Za-z_]+', namespace):
> +    if not re.match(r'^ipa\.[0-9A-Za-z_]+', namespace):

This looks reasonable to me.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>          raise Exception('Namespace must be of the form "ipa.{pipeline_name}"')
>  
>  def ValidateInterfaces(interfaces):
> -- 
> 2.42.0
>
Laurent Pinchart Jan. 9, 2024, 12:52 p.m. UTC | #2
On Tue, Jan 09, 2024 at 12:44:03PM +0000, Kieran Bingham via libcamera-devel wrote:
> Quoting Milan Zamazal via libcamera-devel (2024-01-05 13:16:21)
> > Python 3.12 starts emitting the following warning when building libcamera:
> > 
> >   .../utils/ipc/generators/mojom_libcamera_generator.py:372:
> >   SyntaxWarning: invalid escape sequence '\.'
> >     if not re.match('^ipa\.[0-9A-Za-z_]+', namespace):
> > 
> > `r' prefix is now required before the regexp.
> > 
> > Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
> > ---
> >  utils/ipc/generators/mojom_libcamera_generator.py | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/utils/ipc/generators/mojom_libcamera_generator.py b/utils/ipc/generators/mojom_libcamera_generator.py
> > index 1a629f9d..582818c9 100644
> > --- a/utils/ipc/generators/mojom_libcamera_generator.py
> > +++ b/utils/ipc/generators/mojom_libcamera_generator.py
> > @@ -369,7 +369,7 @@ def ValidateNamespace(namespace):
> >      if namespace == '':
> >          raise Exception('Must have a namespace')
> >  
> > -    if not re.match('^ipa\.[0-9A-Za-z_]+', namespace):
> > +    if not re.match(r'^ipa\.[0-9A-Za-z_]+', namespace):
> 
> This looks reasonable to me.
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> >          raise Exception('Namespace must be of the form "ipa.{pipeline_name}"')
> >  
> >  def ValidateInterfaces(interfaces):

Patch
diff mbox series

diff --git a/utils/ipc/generators/mojom_libcamera_generator.py b/utils/ipc/generators/mojom_libcamera_generator.py
index 1a629f9d..582818c9 100644
--- a/utils/ipc/generators/mojom_libcamera_generator.py
+++ b/utils/ipc/generators/mojom_libcamera_generator.py
@@ -369,7 +369,7 @@  def ValidateNamespace(namespace):
     if namespace == '':
         raise Exception('Must have a namespace')
 
-    if not re.match('^ipa\.[0-9A-Za-z_]+', namespace):
+    if not re.match(r'^ipa\.[0-9A-Za-z_]+', namespace):
         raise Exception('Namespace must be of the form "ipa.{pipeline_name}"')
 
 def ValidateInterfaces(interfaces):