[3/7] framework/ssh_pexpect: Remove duplicate regex flags

Message ID 20230414125255.67812-4-akihiko.odaki@daynix.com (mailing list archive)
State Accepted
Headers
Series Fix for Fedora 37 |

Commit Message

Akihiko Odaki April 14, 2023, 12:52 p.m. UTC
  The regex pattern "(?i)" sets global re.I flag. Not only the duplicate
regex flags are redundant, but the flags not placed at the start of the
regex makes it incompatible with Python 3.11, according to:
https://docs.python.org/3.11/library/re.html#regular-expression-syntax

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 framework/ssh_pexpect.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index 97406896..2132c066 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -50,7 +50,7 @@  class SSHPexpect:
                             original_prompt="[$#>]",
                             port=self.port,
                             login_timeout=20,
-                            password_regex=r"(?i)(?:password:)|(?:passphrase for key)|(?i)(password for .+:)",
+                            password_regex=r"(?i)(?:password:)|(?:passphrase for key)|(password for .+:)",
                         )
                     except Exception as e:
                         print(e)
@@ -68,7 +68,7 @@  class SSHPexpect:
                     self.username,
                     self.password,
                     original_prompt="[$#>]",
-                    password_regex=r"(?i)(?:password:)|(?:passphrase for key)|(?i)(password for .+:)",
+                    password_regex=r"(?i)(?:password:)|(?:passphrase for key)|(password for .+:)",
                 )
             self.send_expect("stty -echo", "#")
             self.send_expect("stty columns 1000", "#")