Re: [pypy-dev] Interactive fails on pypy

Yep... Are there plans to implement the missing functions? Thanks, P 2011/6/8 Caleb Hattingh <caleb.hattingh@gmail.com>
On 8 June 2011 11:15, Paolo Basso <pa.basso@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'
Maybe this message in lib_pypy/msvcrt.py line 7 has something to do with it:
# XXX incomplete: implemented only functions needed by subprocess.py

Hi, 2011/6/8 Paolo Basso <pa.basso@gmail.com>:
if msvcrt.kbhit(): AttributeError: 'module' object has no attribute 'kbhit'
The msvcrt module is implemented in pure Python (in pypy_lib/msvcrt.py) This function seems easy to add. Patches are welcome! -- Amaury Forgeot d'Arc

Thanks for your help, I tryed to add the patch but still have the same problem... Attached are the msvcrt module as I modified it and the code I tryed to run. P 2011/6/8 Amaury Forgeot d'Arc <amauryfa@gmail.com>
Hi,
2011/6/8 Paolo Basso <pa.basso@gmail.com>:
if msvcrt.kbhit(): AttributeError: 'module' object has no attribute 'kbhit'
The msvcrt module is implemented in pure Python (in pypy_lib/msvcrt.py) This function seems easy to add. Patches are welcome!
-- Amaury Forgeot d'Arc

Ok, I solved the problem, the patch works great (thanks Thomas) but the problem was a conflict with the python 2.6 library from which the readline.py module was loaded. Is it normal that it happens or it a problem of my configuration? I solved by using the sys.path.insert(0, "path of the pypy_lib in my drive") but I wonder if there is a better way so that I don't need to add that line every time. Thanks, P 2011/6/10 Paolo Basso <pa.basso@gmail.com>
Thanks for your help, I tryed to add the patch but still have the same problem...
Attached are the msvcrt module as I modified it and the code I tryed to run.
P
2011/6/8 Amaury Forgeot d'Arc <amauryfa@gmail.com>
Hi,
2011/6/8 Paolo Basso <pa.basso@gmail.com>:
if msvcrt.kbhit(): AttributeError: 'module' object has no attribute 'kbhit'
The msvcrt module is implemented in pure Python (in pypy_lib/msvcrt.py) This function seems easy to add. Patches are welcome!
-- Amaury Forgeot d'Arc

On 10/06/11 18:00, Paolo Basso wrote:
Ok, I solved the problem, the patch works great (thanks Thomas) but the problem was a conflict with the python 2.6 library from which the readline.py module was loaded. Is it normal that it happens or it a problem of my configuration?
uhm, it seems that something is wrong. PyPy should not try to load the modules of cpython's stdlib (it doesn't even know if/where it is installed!) What is your PYTHONPATH? And your sys.path? ciao, Anto

sys.path da pypy: ['', 'C:\\Python26\\DLLs', 'C:\\Python26\\Lib', 'C:\\Python26\\Lib\\site-package s', 'C:\\PyPy\\pypy-1.5.0a0-win32', 'C:\\PyPy\\pypy-1.5.0a0-win32\\lib_pypy', 'C :\\PyPy\\pypy-1.5.0a0-win32\\lib-python\\modified-2.7', 'C:\\PyPy\\pypy-1.5.0a0- win32\\lib-python\\2.7', 'C:\\PyPy\\pypy-1.5.0a0-win32\\lib-python\\modified-2.7 \\lib-tk' <file://lib-tk'/>, 'C:\\PyPy\\pypy-1.5.0a0-win32\\lib-python\\2.7\\lib-tk'] PYTHONPATH C:\Python26\DLLs;C:\Python26\Lib;C:\Python26\Lib\site-packages; 2011/6/10 Antonio Cuni <anto.cuni@gmail.com>
On 10/06/11 18:00, Paolo Basso wrote:
Ok, I solved the problem, the patch works great (thanks Thomas) but the problem was a conflict with the python 2.6 library from which the readline.py module was loaded. Is it normal that it happens or it a problem of my configuration?
uhm, it seems that something is wrong. PyPy should not try to load the modules of cpython's stdlib (it doesn't even know if/where it is installed!)
What is your PYTHONPATH? And your sys.path?
ciao, Anto

On 10/06/11 18:32, Paolo Basso wrote:
PYTHONPATH
C:\Python26\DLLs;C:\Python26\Lib;C:\Python26\Lib\site-packages;
this is the problem. You are explicitly telling pypy to import modules from cpython's stdlib. Why do you have such a pythonpath, btw? It's not needed, CPython can determine its own automatically. ciao, Anto

Why do you have such a pythonpath, btw?
I have no idea... However I removed the PYTHONPATH and now everything works fine, thanks. P 2011/6/10 Antonio Cuni <anto.cuni@gmail.com>
On 10/06/11 18:32, Paolo Basso wrote:
PYTHONPATH
C:\Python26\DLLs;C:\Python26\Lib;C:\Python26\Lib\site-packages;
this is the problem. You are explicitly telling pypy to import modules from cpython's stdlib.
Why do you have such a pythonpath, btw? It's not needed, CPython can determine its own automatically.
ciao, Anto

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@gmail.com <mailto:caleb.hattingh@gmail.com>>
On 8 June 2011 11:15, Paolo Basso <pa.basso@gmail.com <mailto:pa.basso@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.'''

Am 08.06.2011 18:28, schrieb Amaury Forgeot d'Arc:
Hello Thomas!
2011/6/8 Thomas Heller<theller@ctypes.org>:
+putwch.argtypes = [ctypes.c_char]
It's probably a c_wchar here...
Sure, sorry for that.
Still working with ctypes? ;-)
With ctypes - yes, of course. It's the foundation of some frameworks that we use in our company. On ctypes - no, not currently. With the exception of pypy - I was totally speechless yesterday when I tried out pypy for the first time, and found that most of our software works fine with pypy instead of cPython after disabling some too fancy stuff. Really great work of the pypy crowd! Well, comtypes doesn't work with pypy, but it uses some really deep things from ctypes that is implemented differently in pypy. Maybe I can fix that ;-) Thanks, Thomas

2011/6/8 Thomas Heller <theller@ctypes.org>:
Well, comtypes doesn't work with pypy, but it uses some really deep things from ctypes that is implemented differently in pypy. Maybe I can fix that ;-)
A few years ago I did implement many things for comtypes. I went to the point where it could generate Python wrappers for COM classes (I tried on some Excel class IIRC) Unfortunately, none of these features are tested or documented, so it's more than likely that the recent evolution of pypy's ctypes broke it. -- Amaury Forgeot d'Arc

Thanks for the patch, is there a nightly build of pypy 1.5 somewhere or I have to build it myself from updated source? In this second case is there a "tutorial" on how to build the source? Thanks, P P.S. I look forward to attend the pypy sprint in Genoa at the end of this month, at least I can learn a little bit more there :) 2011/6/8 Amaury Forgeot d'Arc <amauryfa@gmail.com>
2011/6/8 Thomas Heller <theller@ctypes.org>:
Well, comtypes doesn't work with pypy, but it uses some really deep things from ctypes that is implemented differently in pypy. Maybe I can fix that ;-)
A few years ago I did implement many things for comtypes. I went to the point where it could generate Python wrappers for COM classes (I tried on some Excel class IIRC)
Unfortunately, none of these features are tested or documented, so it's more than likely that the recent evolution of pypy's ctypes broke it.
-- Amaury Forgeot d'Arc _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev

Hi, 2011/6/9 Paolo Basso <pa.basso@gmail.com>:
Thanks for the patch, is there a nightly build of pypy 1.5 somewhere or I have to build it myself from updated source? In this second case is there a "tutorial" on how to build the source?
Unfortunately we cannot build win32 versions at the moment. Translating pypy yourself is not too difficult: http://doc.pypy.org/en/latest/getting-started-python.html?translating-the-py... http://doc.pypy.org/en/latest/windows.html OTOH, the previous patch only touches the pure Python standard library, and does not need another compilation! Just add the lines to your existing version of lib_pypy\msvcrt.py -- Amaury Forgeot d'Arc
participants (4)
-
Amaury Forgeot d'Arc
-
Antonio Cuni
-
Paolo Basso
-
Thomas Heller