Skip to contentSkip to conversation

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

PATCH In review Alejandro Vallejo 3 participants 4 messages Oct 11, 2023

lore
Share & tools
lore
#0 lore raw

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

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:

---
 tools/pygrub/src/pygrub | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/pygrub/src/pygrub +1 -1
index dcdfc04ff0..541e562327 100755
@@ -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
Signature · 1 line
2.34.1
#1 lore raw
Quoted 16 lines · Alejandro Vallejo

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:

---
 tools/pygrub/src/pygrub | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/pygrub/src/pygrub +0 -0
index dcdfc04ff0..541e562327 100755

tools/pygrub/src/pygrub class Grub: · line 737

Quoted 8 lines
tools/pygrub/src/pygrub +1 -1
@@ -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

#2 lore raw
In reply to Alejandro Vallejo
Quoted 16 lines · Alejandro Vallejo

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:

---
 tools/pygrub/src/pygrub | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/pygrub/src/pygrub +0 -0
index dcdfc04ff0..541e562327 100755

tools/pygrub/src/pygrub class Grub: · line 737

Quoted 8 lines
tools/pygrub/src/pygrub +1 -1
@@ -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

#3 lore raw

Hi Andrew, Alejandro,

Quoted 14 lines · Andrew Cooper
Quoted 11 lines · Alejandro Vallejo

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:

---
tools/pygrub/src/pygrub | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

tools/pygrub/src/pygrub class Grub: · line 737

Quoted 13 lines
tools/pygrub/src/pygrub +0 -0
index dcdfc04ff0..541e562327 100755
@@ -731,7 +731,7 @@ class Grub:

def get_entry_idx(cf, entry):
# first, see if the given entry is numeric
try:

tools/pygrub/src/pygrub +1 -1
-        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.

Kind regards,
Henry

Quoted 4 lines

Thanks,

~Andrew