[PATCH] tools/pygrub: Fix pygrub's --entry flag for python3

Alejandro Vallejo posted 1 patch 6 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20231011122520.1826-1-alejandro.vallejo@cloud.com
tools/pygrub/src/pygrub | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tools/pygrub: Fix pygrub's --entry flag for python3
Posted by Alejandro Vallejo 6 months, 3 weeks ago
string.atoi() has been deprecated since Python 2.0, has a big scary warning
in the python2.7 docs and is absent from python3 altogether. int() does the
same thing and is compatible with both.

See https://docs.python.org/2/library/string.html#string.atoi:

Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
---
 tools/pygrub/src/pygrub | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
index dcdfc04ff0..541e562327 100755
--- a/tools/pygrub/src/pygrub
+++ b/tools/pygrub/src/pygrub
@@ -731,7 +731,7 @@ class Grub:
 def get_entry_idx(cf, entry):
     # first, see if the given entry is numeric
     try:
-        idx = string.atoi(entry)
+        idx = int(entry)
         return idx
     except ValueError:
         pass
-- 
2.34.1
Re: [PATCH for-4.18] tools/pygrub: Fix pygrub's --entry flag for python3
Posted by Andrew Cooper 6 months, 3 weeks ago
On 11/10/2023 8:25 pm, Alejandro Vallejo wrote:
> string.atoi() has been deprecated since Python 2.0, has a big scary warning
> in the python2.7 docs and is absent from python3 altogether. int() does the
> same thing and is compatible with both.
>
> See https://docs.python.org/2/library/string.html#string.atoi:
>
> Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
> ---
>  tools/pygrub/src/pygrub | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
> index dcdfc04ff0..541e562327 100755
> --- a/tools/pygrub/src/pygrub
> +++ b/tools/pygrub/src/pygrub
> @@ -731,7 +731,7 @@ class Grub:
>  def get_entry_idx(cf, entry):
>      # first, see if the given entry is numeric
>      try:
> -        idx = string.atoi(entry)
> +        idx = int(entry)
>          return idx
>      except ValueError:
>          pass

CC Henry for 4.18.  This was discovered late in the XSA-443 work and is
one small extra bit of Python3 work.

Thanks,

~Andrew

Re: [PATCH for-4.18] tools/pygrub: Fix pygrub's --entry flag for python3
Posted by Andrew Cooper 6 months, 3 weeks ago
On 11/10/2023 8:25 pm, Alejandro Vallejo wrote:
> string.atoi() has been deprecated since Python 2.0, has a big scary warning
> in the python2.7 docs and is absent from python3 altogether. int() does the
> same thing and is compatible with both.
>
> See https://docs.python.org/2/library/string.html#string.atoi:
>
> Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
> ---
>  tools/pygrub/src/pygrub | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
> index dcdfc04ff0..541e562327 100755
> --- a/tools/pygrub/src/pygrub
> +++ b/tools/pygrub/src/pygrub
> @@ -731,7 +731,7 @@ class Grub:
>  def get_entry_idx(cf, entry):
>      # first, see if the given entry is numeric
>      try:
> -        idx = string.atoi(entry)
> +        idx = int(entry)
>          return idx
>      except ValueError:
>          pass

CC Henry for 4.18.  This was discovered late in the XSA-443 work and is
one small extra bit of Python3 work.

Thanks,

~Andrew

Re: [PATCH for-4.18] tools/pygrub: Fix pygrub's --entry flag for python3
Posted by Henry Wang 6 months, 3 weeks ago
Hi Andrew, Alejandro,

> On Oct 11, 2023, at 21:39, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> 
> On 11/10/2023 8:25 pm, Alejandro Vallejo wrote:
>> string.atoi() has been deprecated since Python 2.0, has a big scary warning
>> in the python2.7 docs and is absent from python3 altogether. int() does the
>> same thing and is compatible with both.
>> 
>> See https://docs.python.org/2/library/string.html#string.atoi:
>> 
>> Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
>> ---
>> tools/pygrub/src/pygrub | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
>> index dcdfc04ff0..541e562327 100755
>> --- a/tools/pygrub/src/pygrub
>> +++ b/tools/pygrub/src/pygrub
>> @@ -731,7 +731,7 @@ class Grub:
>> def get_entry_idx(cf, entry):
>>     # first, see if the given entry is numeric
>>     try:
>> -        idx = string.atoi(entry)
>> +        idx = int(entry)
>>         return idx
>>     except ValueError:
>>         pass
> 
> CC Henry for 4.18.  This was discovered late in the XSA-443 work and is
> one small extra bit of Python3 work.

Thanks.

Release-acked-by: Henry Wang <Henry.Wang@arm.com>

Kind regards,
Henry


> 
> Thanks,
> 
> ~Andrew