diff mbox series

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

Message ID 20231011122520.1826-1-alejandro.vallejo@cloud.com (mailing list archive)
State New, archived
Headers show
Series tools/pygrub: Fix pygrub's --entry flag for python3 | expand

Commit Message

Alejandro Vallejo Oct. 11, 2023, 12:25 p.m. UTC
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(-)

Comments

Andrew Cooper Oct. 11, 2023, 1:39 p.m. UTC | #1
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
Andrew Cooper Oct. 11, 2023, 1:39 p.m. UTC | #2
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
Henry Wang Oct. 11, 2023, 1:41 p.m. UTC | #3
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
diff mbox series

Patch

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