diff mbox series

[scarthgap,2.8,3/3] bb/fetch2/__init__.py: remove a DeprecationWarning in uri_replace()

Message ID 5bdc63d1647e21a530568c0635d95c17354a18db.1757523235.git.steve@sakoman.com
State New
Headers show
Series [scarthgap,2.8,1/3] Use a "fork" multiprocessing context | expand

Commit Message

Steve Sakoman Sept. 10, 2025, 4:56 p.m. UTC
From: Bin Lan <bin.lan.cn@windriver.com>

There is the following warning when executing to bitbake linux-yocto:
  bitbake/lib/bb/fetch2/__init__.py:464: DeprecationWarning: 'count' is passed as positional argument

This is because the 4th parameter of re.sub(pattern, repl, string, count=0, flags=0)
is a keyword parameter. We use keyword arguments for parameters that are not positional.

Signed-off-by: Bin Lan <bin.lan.cn@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 lib/bb/fetch2/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

chris.laplante@agilent.com Sept. 23, 2025, 5:22 p.m. UTC | #1
Hi Steve,

> From: Bin Lan <bin.lan.cn@windriver.com>
> 
> There is the following warning when executing to bitbake linux-yocto:
>   bitbake/lib/bb/fetch2/__init__.py:464: DeprecationWarning: 'count' is passed
> as positional argument
> 
> This is because the 4th parameter of re.sub(pattern, repl, string, count=0,
> flags=0) is a keyword parameter. We use keyword arguments for parameters
> that are not positional.
> 
> Signed-off-by: Bin Lan <bin.lan.cn@windriver.com>
> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
> Signed-off-by: Steve Sakoman <steve@sakoman.com>
> ---
>  lib/bb/fetch2/__init__.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py index
> 1a6ff25d4..7b75d5d83 100644
> --- a/lib/bb/fetch2/__init__.py
> +++ b/lib/bb/fetch2/__init__.py
> @@ -460,7 +460,7 @@ def uri_replace(ud, uri_find, uri_replace,
> replacements, d, mirrortarball=None):
>                  for k in replacements:
>                      uri_replace_decoded[loc] = uri_replace_decoded[loc].replace(k,
> replacements[k])
>                  #bb.note("%s %s %s" % (regexp, uri_replace_decoded[loc],
> uri_decoded[loc]))
> -                result_decoded[loc] = re.sub(regexp, uri_replace_decoded[loc],
> uri_decoded[loc], 1)
> +                result_decoded[loc] = re.sub(regexp,
> + uri_replace_decoded[loc], uri_decoded[loc], count=1)
>              if loc == 2:
>                  # Handle path manipulations
>                  basename = None
> --
> 2.43.0

I think this cherry-pick got swallowed up somewhere as I don't see it on 2.8. Do you need me to resubmit it?

Thanks,
Chris
diff mbox series

Patch

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index 1a6ff25d4..7b75d5d83 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -460,7 +460,7 @@  def uri_replace(ud, uri_find, uri_replace, replacements, d, mirrortarball=None):
                 for k in replacements:
                     uri_replace_decoded[loc] = uri_replace_decoded[loc].replace(k, replacements[k])
                 #bb.note("%s %s %s" % (regexp, uri_replace_decoded[loc], uri_decoded[loc]))
-                result_decoded[loc] = re.sub(regexp, uri_replace_decoded[loc], uri_decoded[loc], 1)
+                result_decoded[loc] = re.sub(regexp, uri_replace_decoded[loc], uri_decoded[loc], count=1)
             if loc == 2:
                 # Handle path manipulations
                 basename = None