mirror of
https://github.com/ARM-software/devlib.git
synced 2025-09-23 12:21:54 +01:00
target: ensure shell_prompt is a bytes_regex
shell_prompt gets passed into expect and therefore must be encoded as bytes on Python 3.
This commit is contained in:
committed by
setrofim
parent
7e942cdd4a
commit
69cd3be96c
@@ -26,6 +26,7 @@ is not the best language to use for configuration.
|
||||
|
||||
"""
|
||||
import math
|
||||
import re
|
||||
import sys
|
||||
from functools import total_ordering
|
||||
|
||||
@@ -135,7 +136,8 @@ if sys.version_info[0] == 3:
|
||||
if isinstance(value, regex_type):
|
||||
if isinstance(value.pattern, str):
|
||||
return value
|
||||
return re.compile(value.pattern.decode())
|
||||
return re.compile(value.pattern.decode(),
|
||||
value.flags | re.UNICODE)
|
||||
else:
|
||||
if isinstance(value, bytes):
|
||||
value = value.decode()
|
||||
@@ -146,7 +148,8 @@ if sys.version_info[0] == 3:
|
||||
if isinstance(value, regex_type):
|
||||
if isinstance(value.pattern, bytes):
|
||||
return value
|
||||
return re.compile(value.pattern.encode(sys.stdout.encoding))
|
||||
return re.compile(value.pattern.encode(sys.stdout.encoding),
|
||||
value.flags & ~re.UNICODE)
|
||||
else:
|
||||
if isinstance(value, str):
|
||||
value = value.encode(sys.stdout.encoding)
|
||||
|
Reference in New Issue
Block a user