diff options
author | David O'Shea <doshea@doshea-centos-x86-64.adl.quantum.com> | 2014-08-01 17:09:32 +0930 |
---|---|---|
committer | David O'Shea <doshea@doshea-centos-x86-64.adl.quantum.com> | 2014-08-01 17:09:32 +0930 |
commit | 6236c1406d91b5174def54c3a1441391ab29a1c2 (patch) | |
tree | e9f9db5b83b5ec7359c825968b98701a61341851 | |
parent | db34b8fed2c21b8b790d2710fde1004d49c8f00e (diff) | |
download | pexpect-6236c1406d91b5174def54c3a1441391ab29a1c2.tar.gz |
Rename codec and codec_errors to encoding and encoding_errors respectively.
-rw-r--r-- | pexpect/screen.py | 20 | ||||
-rwxr-xr-x | tests/test_ansi.py | 6 |
2 files changed, 13 insertions, 13 deletions
diff --git a/pexpect/screen.py b/pexpect/screen.py index dfa3eec..6cd2452 100644 --- a/pexpect/screen.py +++ b/pexpect/screen.py @@ -69,22 +69,22 @@ class screen: Characters are represented internally using unicode. Methods that accept input characters, when passed 'bytes' (which in Python 2 is equivalent to - 'str'), convert them from the encoding specified in the 'codec' parameter - to the constructor. Methods that return screen contents return unicode - strings, with the exception of __str__() under Python 2 and __bytes__(). ''' - def __init__ (self, r=24,c=80,codec='latin-1',codec_errors='replace'): + 'str'), convert them from the encoding specified in the 'encoding' + parameter to the constructor. Methods that return screen contents return + unicode strings, with the exception of __str__() under Python 2 and __bytes__(). ''' + def __init__ (self, r=24,c=80,encoding='latin-1',encoding_errors='replace'): '''This initializes a blank screen of the given dimensions.''' self.rows = r self.cols = c - if codec is not None: - self.decoder = codecs.getincrementaldecoder(codec)(codec_errors) - self.encoder = codecs.getencoder(codec) - self.codec_errors = codec_errors + if encoding is not None: + self.decoder = codecs.getincrementaldecoder(encoding)(encoding_errors) + self.encoder = codecs.getencoder(encoding) + self.encoding_errors = encoding_errors else: self.decoder = None self.encoder = None - self.codec_errors = None + self.encoding_errors = None self.cur_r = 1 self.cur_c = 1 self.cur_saved_r = 1 @@ -105,7 +105,7 @@ class screen: '''This converts from the internal coding system (unicode) to the external one (as passed to the constructor). ''' if self.encoder is not None: - return self.encoder(s,self.codec_errors)[0] + return self.encoder(s,self.encoding_errors)[0] else: return unicode(s) diff --git a/tests/test_ansi.py b/tests/test_ansi.py index 48d92a8..4806bff 100755 --- a/tests/test_ansi.py +++ b/tests/test_ansi.py @@ -157,7 +157,7 @@ class ansiTestCase (PexpectTestCase.PexpectTestCase): characters, where the encoding of each character consists of multiple bytes, the characters are correctly decoded. Incremental decoding is also tested.""" - s = ANSI.ANSI(2, 10, codec='utf-8') + s = ANSI.ANSI(2, 10, encoding='utf-8') # This is the UTF-8 encoding of the UCS character "HOURGLASS" # followed by the UTF-8 encoding of the UCS character # "KEYBOARD". These characters can't be encoded in cp437 or @@ -175,7 +175,7 @@ class ansiTestCase (PexpectTestCase.PexpectTestCase): def test_unicode(self): """Test passing in of a unicode string.""" - s = ANSI.ANSI(2, 10, codec="utf-8") + s = ANSI.ANSI(2, 10, encoding="utf-8") s.write(u'\u231b\u2328') assert unicode(s) == u'\u231b\u2328 \n ' assert bytes(s) == b'\xe2\x8c\x9b\xe2\x8c\xa8 \n ' @@ -187,7 +187,7 @@ class ansiTestCase (PexpectTestCase.PexpectTestCase): def test_decode_error(self): """Test that default handling of decode errors replaces the invalid characters.""" - s = ANSI.ANSI(2, 10, codec="ascii") + s = ANSI.ANSI(2, 10, encoding="ascii") s.write(b'\xff') # a non-ASCII character # In unicode, the non-ASCII character is replaced with # REPLACEMENT CHARACTER. |