[pypy-commit] pyrepl msabramo/ord_char_python3: pyrepl/unix_eventqueue.py: Fix Python 3 ord(char) issue

Marc Abramowitz noreply at buildbot.pypy.org
Sat Mar 8 09:27:27 CET 2014


Author: Marc Abramowitz <marc at marc-abramowitz.com>
Branch: msabramo/ord_char_python3
Changeset: r238:0cd9ad59040f
Date: 2014-02-28 23:09 +0000
http://bitbucket.org/pypy/pyrepl/changeset/0cd9ad59040f/

Log:	pyrepl/unix_eventqueue.py: Fix Python 3 ord(char) issue

	In Python 3, byte strings are composed of ints, so no need to call
	ord() on the elements. Solves a test failure:

	 testing/test_unix_reader.py:11: in test_simple >
	q.push(c) pyrepl/unix_eventqueue.py:103: in push >
	self.buf.append(ord(char)) E TypeError: ord() expected
	string of length 1, but int found

diff --git a/pyrepl/unix_eventqueue.py b/pyrepl/unix_eventqueue.py
--- a/pyrepl/unix_eventqueue.py
+++ b/pyrepl/unix_eventqueue.py
@@ -100,7 +100,8 @@
         self.events.append(event)
 
     def push(self, char):
-        self.buf.append(ord(char))
+        ord_char = char if isinstance(char, int) else ord(char)
+        self.buf.append(ord_char)
         if char in self.k:
             if self.k is self.ck:
                 #sanity check, buffer is empty when a special key comes


More information about the pypy-commit mailing list