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

Akihiko Odaki akihiko.odaki at daynix.com
Fri Apr 14 14:52:51 CEST 2023


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 at daynix.com>
---
 framework/ssh_pexpect.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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", "#")
-- 
2.40.0



More information about the dts mailing list