[pypy-dev] Interactive fails on pypy
Thomas Heller
theller at ctypes.org
Wed Jun 8 17:56:25 CEST 2011
Am 08.06.2011 11:27, schrieb Paolo Basso:
> Yep... Are there plans to implement the missing functions?
> Thanks,
> P
>
> 2011/6/8 Caleb Hattingh <caleb.hattingh at gmail.com
> <mailto:caleb.hattingh at gmail.com>>
>
> On 8 June 2011 11:15, Paolo Basso <pa.basso at gmail.com
> <mailto:pa.basso at gmail.com>> wrote:
>
> I tryed to run the attached code with pypy but it fails (it
> works correctly with python 2.6).
> Can anybody tell me why? Thanks.
>
>
> Error is this:
>
> 0
> Traceback (most recent call last):
> File "app_main.py", line 53, in run_toplevel
> File "test.py", line 25, in <module>
> it.ESC_test("TEST",1.0)
> File "test.py", line 14, in ESC_test
> if msvcrt.kbhit():
> AttributeError: 'module' object has no attribute 'kbhit'
>
Here is a patch against pypy 1.5, only slightly tested.
Thomas
diff -u c:\pypy\lib_pypy\msvcrt.py.orig c:\pypy\lib_pypy\msvcrt.py
--- c:\pypy\lib_pypy\msvcrt.py.orig Wed Jun 08 15:53:02 2011
+++ c:\pypy\lib_pypy\msvcrt.py Wed Jun 08 15:53:02 2011
@@ -38,6 +38,43 @@
_locking.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_int]
_locking.restype = ctypes.c_int
+kbhit = _c._kbhit
+kbhit.argtypes = []
+kbhit.restype = ctypes.c_int
+
+getch = _c._getch
+getch.argtypes = []
+getch.restype = ctypes.c_char
+
+getwch = _c._getwch
+getwch.argtypes = []
+getwch.restype = ctypes.c_wchar
+
+getche = _c._getche
+getche.argtypes = []
+getche.restype = ctypes.c_char
+
+getwche = _c._getwche
+getwche.argtypes = []
+getwche.restype = ctypes.c_wchar
+
+putch = _c._putch
+putch.restype = None
+putch.argtypes = [ctypes.c_char]
+
+putwch = _c._putwch
+putwch.restype = None
+putwch.argtypes = [ctypes.c_char]
+
+ungetch = _c._ungetch
+ungetch.restype = None
+ungetch.argtypes = [ctypes.c_char]
+
+ungetwch = _c._ungetwch
+ungetwch.restype = None
+ungetwch.argtypes = [ctypes.c_wchar]
+
+
@builtinify
def locking(fd, mode, nbytes):
'''lock or unlock a number of bytes in a file.'''
More information about the pypy-dev
mailing list