summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremerson.prado <emerson.prado@dataprev.gov.br>2019-03-05 14:25:17 -0300
committeremerson.prado <emerson.prado@dataprev.gov.br>2019-03-05 14:25:17 -0300
commit5834c9631b12efd53dc9bc21190f895bb0a3d31a (patch)
tree5dc19c4d1d2e4a569df433efdb72b139e37b3e35
parentec916dd69f4eabee35dc62c903c16cf9131d49d0 (diff)
downloadpexpect-5834c9631b12efd53dc9bc21190f895bb0a3d31a.tar.gz
Coerce compiled regex patterns to non-bytes type in non-bytes mode
-rw-r--r--pexpect/spawnbase.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/pexpect/spawnbase.py b/pexpect/spawnbase.py
index 5bf10a5..ee96cfa 100644
--- a/pexpect/spawnbase.py
+++ b/pexpect/spawnbase.py
@@ -143,6 +143,9 @@ class SpawnBase(object):
p = r.pattern
if self.encoding is None and not isinstance(p, bytes):
return re.compile(p.encode('utf-8'))
+ # And vice-versa
+ elif self.encoding is not None and isinstance(p, bytes):
+ return re.compile(p.decode('utf-8'))
return r
def _coerce_send_string(self, s):