Hello,
After some work I managed to run the pypy translation using python
2.5. I know that it is not the best moment because of the imminent
release, so feel free to put this under your pillow for now.
With some changes, I successfully translate pypy-c on Windows (with
--gc=framework), and the produced program seems to work. But I did not
rerun the entire test suite.
I join the patch (too shy to commit it), with some comments:
1/ The struct module was rewritten in python 2.5. Better use the full
python implementation provided by pypy.
2/ KeyboardInterrupt is used by RPython; translation of exceptions
must now process all classes derived from BaseException.
3/ This one was difficult, and I am not sure of the correction: with
2.5, IMPORT_NAME takes a new parameter to specify the "relative
import" level. CPython-2.5 generate pcode with this extra parameter,
but pypy-2.4 can ignore it.
The hard part is that pyopcode.py must interpret pcode coming from
both the pypy ast compiler and CPython .pyc files. Anyway the
implementation in ceval.c itself is not clear (it seems to try to be
compatible with 2.4 pcode. How can this work?).
4/ 5/ Easy corrections (not specific to 2.5) while trying the --jit
option on Windows: platform.machine() is empty on my machine, and
codebuf_nt is expected to export a PTR type.
Index: pypy/module/array/app_array.py
================================================================
--- pypy/module/array/app_array.py (revision 41035)
+++ pypy/module/array/app_array.py (working copy)
@@ -24,7 +24,7 @@
array(typecode [, initializer]) -- create a new array
"""
import sys
-from struct import pack, unpack
+from pypy.lib.struct import pack, unpack
if sys.maxunicode == 65535:
UNICODE_SIZE = 2
Index: pypy/annotation/annrpython.py
================================================================
--- pypy/annotation/annrpython.py (revision 41035)
+++ pypy/annotation/annrpython.py (working copy)
@@ -8,6 +8,7 @@
from pypy.objspace.flow.model import Variable, Constant
from pypy.objspace.flow.model import FunctionGraph
from pypy.objspace.flow.model import c_last_exception, checkgraph
+from py.builtin import BaseException
import py
log = py.log.Producer("annrpython")
py.log.setconsumer("annrpython", ansi_log)
@@ -622,7 +623,7 @@
last_exc_value_var = link.last_exc_value # may be None
for non-exception link
if isinstance(link.exitcase, (types.ClassType, type)) \
- and issubclass(link.exitcase, Exception):
+ and issubclass(link.exitcase, BaseException):
assert last_exception_var and last_exc_value_var
last_exc_value_object =
self.bookkeeper.valueoftype(link.exitcase)
last_exception_object = annmodel.SomeObject()
Index: pypy/interpreter/pyopcode.py
===================================================================
--- pypy/interpreter/pyopcode.py (revision 41035)
+++ pypy/interpreter/pyopcode.py (working copy)
@@ -705,6 +705,12 @@
w_modulename = f.getname_w(nameindex)
modulename = f.space.str_w(w_modulename)
w_fromlist = f.popvalue()
+ # AFA: Python 2.5 relative import
+ # we MAY encounter an additional '-1' parameter
+ if f.valuestackdepth > 0:
+ w_level = f.peekvalue()
+ if space.is_true(space.eq(w_level, space.wrap(-1))):
+ f.popvalue()
w_import = f.get_builtin().getdictvalue_w(f.space, '__import__')
if w_import is None:
raise OperationError(space.w_ImportError,
Index: pypy/jit/codegen/detect_cpu.py
===================================================================
--- pypy/jit/codegen/detect_cpu.py (revision 41035)
+++ pypy/jit/codegen/detect_cpu.py (working copy)
@@ -8,10 +8,13 @@
pass
def autodetect():
+ mach = None
try:
import platform
mach = platform.machine()
except ImportError:
+ pass
+ if not mach:
platform = sys.platform.lower()
if platform.startswith('win'): # assume an Intel Windows
return 'i386'
Index: pypy/jit/codegen/i386/codebuf_nt.py
===================================================================
--- pypy/jit/codegen/i386/codebuf_nt.py (revision 41035)
+++ pypy/jit/codegen/i386/codebuf_nt.py (working copy)
@@ -19,24 +19,24 @@
globals().update(ctypes_platform.configure(CConfig))
# cannot use c_void_p as return value of functions :-(
-LPVOID = ctypes.POINTER(ctypes.c_char)
+PTR = ctypes.POINTER(ctypes.c_char)
VirtualAlloc = ctypes.windll.kernel32.VirtualAlloc
-VirtualAlloc.argtypes = [LPVOID, SIZE_T, DWORD, DWORD]
-VirtualAlloc.restype = LPVOID
+VirtualAlloc.argtypes = [PTR, SIZE_T, DWORD, DWORD]
+VirtualAlloc.restype = PTR
VirtualProtect = ctypes.windll.kernel32.VirtualProtect
-VirtualProtect.argtypes = [LPVOID, SIZE_T, DWORD, ctypes.POINTER(DWORD)]
+VirtualProtect.argtypes = [PTR, SIZE_T, DWORD, ctypes.POINTER(DWORD)]
VirtualProtect.restype = BOOL
VirtualFree = ctypes.windll.kernel32.VirtualFree
-VirtualFree.argtypes = [LPVOID, SIZE_T, DWORD]
+VirtualFree.argtypes = [PTR, SIZE_T, DWORD]
VirtualFree.restype = BOOL
# ____________________________________________________________
def alloc(map_size):
- res = VirtualAlloc(LPVOID(), map_size, MEM_COMMIT|MEM_RESERVE,
+ res = VirtualAlloc(PTR(), map_size, MEM_COMMIT|MEM_RESERVE,
PAGE_EXECUTE_READWRITE)
if not res:
raise MemoryError
--
Amaury Forgeot d'Arc
_______________________________________________
[email protected]
http://codespeak.net/mailman/listinfo/pypy-dev