utils: ipc: extract-docs: Fix escape characters in regex
diff mbox series

Message ID 20240122110104.3206863-1-paul.elder@ideasonboard.com
State Accepted
Commit 81791d2cac70a3f549db85fb2e40e385b24e76fc
Headers show
Series
  • utils: ipc: extract-docs: Fix escape characters in regex
Related show

Commit Message

Paul Elder Jan. 22, 2024, 11:01 a.m. UTC
Newer versions of python now generate a SyntaxWarning (SyntaxError in
the future [1]) for invalid escape sequences. Fix this, as there were
invalid escape sequences in the regexes:

"libcamera/utils/ipc/./extract-docs.py:13: SyntaxWarning: invalid escape
sequence '\/'"

[1] https://docs.python.org/3.12/library/re.html

Reported-by: Nicolas Dufresne <nicolas@ndufresne.ca>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
I'm not actually able to reproduce the warning in the first place, but
from my understanding this should fix the problem. Nicolas, could you
confirm this please?
---
 utils/ipc/extract-docs.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Laurent Pinchart Jan. 22, 2024, 11:17 a.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Mon, Jan 22, 2024 at 08:01:04PM +0900, Paul Elder wrote:
> Newer versions of python now generate a SyntaxWarning (SyntaxError in
> the future [1]) for invalid escape sequences. Fix this, as there were
> invalid escape sequences in the regexes:
> 
> "libcamera/utils/ipc/./extract-docs.py:13: SyntaxWarning: invalid escape
> sequence '\/'"
> 
> [1] https://docs.python.org/3.12/library/re.html
> 
> Reported-by: Nicolas Dufresne <nicolas@ndufresne.ca>
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

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

> ---
> I'm not actually able to reproduce the warning in the first place, but
> from my understanding this should fix the problem. Nicolas, could you
> confirm this please?
> ---
>  utils/ipc/extract-docs.py | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
> index 8f7fff9ff..c2050c998 100755
> --- a/utils/ipc/extract-docs.py
> +++ b/utils/ipc/extract-docs.py
> @@ -10,9 +10,9 @@ import argparse
>  import re
>  import sys
>  
> -regex_block_start = re.compile('^\/\*\*$')
> -regex_block_end = re.compile('^ \*\/$')
> -regex_spdx = re.compile('^\/\* SPDX-License-Identifier: .* \*\/$')
> +regex_block_start = re.compile(r'^/\*\*$')
> +regex_block_end = re.compile(r'^ \*/$')
> +regex_spdx = re.compile(r'^/\* SPDX-License-Identifier: .* \*/$')
>  
>  
>  def main(argv):
Nicolas Dufresne Jan. 22, 2024, 4:33 p.m. UTC | #2
Le lundi 22 janvier 2024 à 20:01 +0900, Paul Elder a écrit :
> Newer versions of python now generate a SyntaxWarning (SyntaxError in
> the future [1]) for invalid escape sequences. Fix this, as there were
> invalid escape sequences in the regexes:
> 
> "libcamera/utils/ipc/./extract-docs.py:13: SyntaxWarning: invalid escape
> sequence '\/'"
> 
> [1] https://docs.python.org/3.12/library/re.html
> 
> Reported-by: Nicolas Dufresne <nicolas@ndufresne.ca>
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

No more warnings, thanks,

Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

> 
> ---
> I'm not actually able to reproduce the warning in the first place, but
> from my understanding this should fix the problem. Nicolas, could you
> confirm this please?
> ---
>  utils/ipc/extract-docs.py | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
> index 8f7fff9ff..c2050c998 100755
> --- a/utils/ipc/extract-docs.py
> +++ b/utils/ipc/extract-docs.py
> @@ -10,9 +10,9 @@ import argparse
>  import re
>  import sys
>  
> -regex_block_start = re.compile('^\/\*\*$')
> -regex_block_end = re.compile('^ \*\/$')
> -regex_spdx = re.compile('^\/\* SPDX-License-Identifier: .* \*\/$')
> +regex_block_start = re.compile(r'^/\*\*$')
> +regex_block_end = re.compile(r'^ \*/$')
> +regex_spdx = re.compile(r'^/\* SPDX-License-Identifier: .* \*/$')
>  
>  
>  def main(argv):

Patch
diff mbox series

diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py
index 8f7fff9ff..c2050c998 100755
--- a/utils/ipc/extract-docs.py
+++ b/utils/ipc/extract-docs.py
@@ -10,9 +10,9 @@  import argparse
 import re
 import sys
 
-regex_block_start = re.compile('^\/\*\*$')
-regex_block_end = re.compile('^ \*\/$')
-regex_spdx = re.compile('^\/\* SPDX-License-Identifier: .* \*\/$')
+regex_block_start = re.compile(r'^/\*\*$')
+regex_block_end = re.compile(r'^ \*/$')
+regex_spdx = re.compile(r'^/\* SPDX-License-Identifier: .* \*/$')
 
 
 def main(argv):