Author: Matti Picus <[email protected]>
Branch:
Changeset: r70282:d2fa62bd86e8
Date: 2014-03-25 17:56 +0200
http://bitbucket.org/pypy/pypy/changeset/d2fa62bd86e8/
Log: merge win32-fixes4, which fixes some tests on win32
diff --git a/lib-python/2.7/test/test_genericpath.py
b/lib-python/2.7/test/test_genericpath.py
--- a/lib-python/2.7/test/test_genericpath.py
+++ b/lib-python/2.7/test/test_genericpath.py
@@ -231,9 +231,12 @@
unicwd = u'\xe7w\xf0'
try:
fsencoding = test_support.TESTFN_ENCODING or "ascii"
- unicwd.encode(fsencoding)
+ asciival = unicwd.encode(fsencoding)
+ v = asciival.find('?')
+ if v >= 0:
+ raise UnicodeEncodeError(fsencoding, unicwd, v, v, asciival)
except (AttributeError, UnicodeEncodeError):
- # FS encoding is probably ASCII
+ # FS encoding is probably ASCII or windows and codepage is
non-Latin1
pass
else:
with test_support.temp_cwd(unicwd):
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -124,3 +124,6 @@
.. branch: refactor_PyErr_SetFromErrnoWithFilename
Add support for PyErr_SetFromErrnoWithFilenameObject to cpyext
+
+.. branch: win32-fixes4
+fix more tests for win32
diff --git a/pypy/module/_codecs/test/test_codecs.py
b/pypy/module/_codecs/test/test_codecs.py
--- a/pypy/module/_codecs/test/test_codecs.py
+++ b/pypy/module/_codecs/test/test_codecs.py
@@ -1,3 +1,5 @@
+import sys
+
class AppTestCodecs:
spaceconfig = {
"usemodules": ['unicodedata', 'struct', 'binascii'],
@@ -137,7 +139,9 @@
class AppTestPartialEvaluation:
- spaceconfig = dict(usemodules=('array',))
+ spaceconfig = dict(usemodules=['array',])
+ if sys.platform == 'win32':
+ spaceconfig['usemodules'].append('_winreg')
def test_partial_utf8(self):
import _codecs
@@ -694,8 +698,18 @@
import sys
if sys.platform != 'win32':
return
+ toencode = u'caf\xe9', 'caf\xe9'
+ try:
+ #test for non-latin1 codepage, more general test needed
+ import _winreg
+ key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
+ r'System\CurrentControlSet\Control\Nls\CodePage')
+ if _winreg.QueryValueEx(key, 'ACP')[0] == u'1255': #non-latin1
+ toencode = u'caf\xbf','caf\xbf'
+ except:
+ assert False, 'cannot test mbcs on this windows system, check code
page'
assert u'test'.encode('mbcs') == 'test'
- assert u'caf\xe9'.encode('mbcs') == 'caf\xe9'
+ assert toencode[0].encode('mbcs') == toencode[1]
assert u'\u040a'.encode('mbcs') == '?' # some cyrillic letter
assert 'cafx\e9'.decode('mbcs') == u'cafx\e9'
diff --git a/pypy/module/cpyext/test/test_eval.py
b/pypy/module/cpyext/test/test_eval.py
--- a/pypy/module/cpyext/test/test_eval.py
+++ b/pypy/module/cpyext/test/test_eval.py
@@ -312,8 +312,9 @@
("get_flags", "METH_NOARGS",
"""
PyCompilerFlags flags;
+ int result;
flags.cf_flags = 0;
- int result = PyEval_MergeCompilerFlags(&flags);
+ result = PyEval_MergeCompilerFlags(&flags);
return Py_BuildValue("ii", result, flags.cf_flags);
"""),
])
diff --git a/rpython/jit/backend/detect_cpu.py
b/rpython/jit/backend/detect_cpu.py
--- a/rpython/jit/backend/detect_cpu.py
+++ b/rpython/jit/backend/detect_cpu.py
@@ -20,10 +20,11 @@
def detect_model_from_c_compiler():
# based on http://sourceforge.net/p/predef/wiki/Architectures/
+ # and http://msdn.microsoft.com/en-us/library/b0084kay.aspx
mapping = {
- MODEL_X86_64: ['__amd64__', '__amd64', '__x86_64__', '__x86_64'],
- MODEL_ARM: ['__arm__', '__thumb__'],
- MODEL_X86: ['i386', '__i386', '__i386__', '__i686__'],
+ MODEL_X86_64: ['__amd64__', '__amd64', '__x86_64__', '__x86_64',
'_M_X64', '_M_AMD64'],
+ MODEL_ARM: ['__arm__', '__thumb__','_M_ARM_EP'],
+ MODEL_X86: ['i386', '__i386', '__i386__', '__i686__','_M_IX86'],
MODEL_PPC_64: ['__powerpc64__'],
}
for k, v in mapping.iteritems():
diff --git a/rpython/jit/backend/llgraph/runner.py
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -66,9 +66,11 @@
self.args = args
class CallDescr(AbstractDescr):
- def __init__(self, RESULT, ARGS, extrainfo):
+ from rpython.rlib.clibffi import FFI_DEFAULT_ABI
+ def __init__(self, RESULT, ARGS, extrainfo, ABI=FFI_DEFAULT_ABI):
self.RESULT = RESULT
self.ARGS = ARGS
+ self.ABI = ABI
self.extrainfo = extrainfo
def __repr__(self):
@@ -428,7 +430,7 @@
try:
return self.descrs[key]
except KeyError:
- descr = CallDescr(RESULT, ARGS, extrainfo)
+ descr = CallDescr(RESULT, ARGS, extrainfo, ABI=cif_description.abi)
self.descrs[key] = descr
return descr
@@ -949,7 +951,7 @@
# graph, not to directly execute the python function
result = self.cpu.maybe_on_top_of_llinterp(func, call_args,
descr.RESULT)
else:
- FUNC = lltype.FuncType(descr.ARGS, descr.RESULT)
+ FUNC = lltype.FuncType(descr.ARGS, descr.RESULT, descr.ABI)
func_to_call = rffi.cast(lltype.Ptr(FUNC), func)
result = func_to_call(*call_args)
del self.force_guard_op
diff --git a/rpython/jit/metainterp/test/test_ajit.py
b/rpython/jit/metainterp/test/test_ajit.py
--- a/rpython/jit/metainterp/test/test_ajit.py
+++ b/rpython/jit/metainterp/test/test_ajit.py
@@ -14,6 +14,7 @@
from rpython.rlib.longlong2float import float2longlong, longlong2float
from rpython.rlib.rarithmetic import ovfcheck, is_valid_int
from rpython.rtyper.lltypesystem import lltype, rffi
+from rpython.translator.tool.cbuild import ExternalCompilationInfo
class BasicTests:
@@ -3228,11 +3229,12 @@
self.check_resops(arraylen_gc=2)
def test_release_gil_flush_heap_cache(self):
+ eci = ExternalCompilationInfo()
if sys.platform == "win32":
- py.test.skip("needs 'time'")
+ eci = ExternalCompilationInfo(libraries=["msvcrt"])
T = rffi.CArrayPtr(rffi.TIME_T)
- external = rffi.llexternal("time", [T], rffi.TIME_T, releasegil=True)
+ external = rffi.llexternal("time", [T], rffi.TIME_T, releasegil=True,
compilation_info=eci)
# Not a real lock, has all the same properties with respect to GIL
# release though, so good for this test.
class Lock(object):
@@ -3920,10 +3922,13 @@
self.interp_operations(f, [])
def test_external_call(self):
+ eci = ExternalCompilationInfo()
+ if sys.platform == "win32":
+ eci = ExternalCompilationInfo(libraries=["msvcrt"])
from rpython.rlib.objectmodel import invoke_around_extcall
T = rffi.CArrayPtr(rffi.TIME_T)
- external = rffi.llexternal("time", [T], rffi.TIME_T)
+ external = rffi.llexternal("time", [T], rffi.TIME_T,
compilation_info=eci)
class Oups(Exception):
pass
diff --git a/rpython/rlib/test/test_clibffi.py
b/rpython/rlib/test/test_clibffi.py
--- a/rpython/rlib/test/test_clibffi.py
+++ b/rpython/rlib/test/test_clibffi.py
@@ -423,11 +423,12 @@
def setup_class(cls):
if sys.platform != 'win32':
py.test.skip("Handle to libc library, Win-only test")
- BaseFfiTest.setup_class(cls)
+ BaseFfiTest.setup_class()
def test_get_libc_handle(self):
handle = get_libc_handle()
print get_libc_name()
- print hex(handle)
- assert handle != 0
- assert handle % 0x1000 == 0
+ print dir(handle)
+ addr = rffi.cast(rffi.INT, handle)
+ assert addr != 0
+ assert addr % 0x1000 == 0
diff --git a/rpython/rlib/test/test_rposix.py b/rpython/rlib/test/test_rposix.py
--- a/rpython/rlib/test/test_rposix.py
+++ b/rpython/rlib/test/test_rposix.py
@@ -25,7 +25,7 @@
def as_unicode(self):
return self.unistr
-class BasePosixUnicode:
+class BasePosixUnicodeOrAscii:
def setup_method(self, method):
self.ufilename = self._get_filename()
try:
@@ -34,9 +34,12 @@
py.test.skip("encoding not good enough")
f.write("test")
f.close()
-
- self.path = UnicodeWithEncoding(self.ufilename)
- self.path2 = UnicodeWithEncoding(self.ufilename + ".new")
+ if sys.platform == 'win32' and isinstance(self.ufilename, str):
+ self.path = self.ufilename
+ self.path2 = self.ufilename + ".new"
+ else:
+ self.path = UnicodeWithEncoding(self.ufilename)
+ self.path2 = UnicodeWithEncoding(self.ufilename + ".new")
def test_open(self):
def f():
@@ -55,8 +58,11 @@
def test_stat(self):
def f():
return rposix.stat(self.path).st_mtime
-
- assert interpret(f, []) == os.stat(self.ufilename).st_mtime
+ if sys.platform == 'win32':
+ #double vs. float, be satisfied with sub-millisec resolution
+ assert abs(interpret(f, []) - os.stat(self.ufilename).st_mtime) <
1e-4
+ else:
+ assert interpret(f, []) == os.stat(self.ufilename).st_mtime
def test_access(self):
def f():
@@ -96,7 +102,11 @@
if sys.platform == 'win32':
def f():
- return u', '.join(rposix.listdir(udir))
+ if isinstance(udir.as_unicode(), str):
+ _udir = udir.as_unicode()
+ else:
+ _udir = udir
+ return u', '.join(rposix.listdir(_udir))
result = interpret(f, [])
assert os.path.basename(self.ufilename) in ll_to_string(result)
else:
@@ -149,11 +159,11 @@
interpret(f, []) # does not crash
-class TestPosixAscii(BasePosixUnicode):
+class TestPosixAscii(BasePosixUnicodeOrAscii):
def _get_filename(self):
return str(udir.join('test_open_ascii'))
-class TestPosixUnicode(BasePosixUnicode):
+class TestPosixUnicode(BasePosixUnicodeOrAscii):
def _get_filename(self):
return (unicode(udir.join('test_open')) +
u'\u65e5\u672c.txt') # "Japan"
diff --git a/rpython/rtyper/lltypesystem/ll2ctypes.py
b/rpython/rtyper/lltypesystem/ll2ctypes.py
--- a/rpython/rtyper/lltypesystem/ll2ctypes.py
+++ b/rpython/rtyper/lltypesystem/ll2ctypes.py
@@ -358,6 +358,13 @@
if isinstance(T, lltype.Ptr):
if isinstance(T.TO, lltype.FuncType):
+
+ functype = ctypes.CFUNCTYPE
+ if sys.platform == 'win32':
+ from rpython.rlib.clibffi import FFI_STDCALL, FFI_DEFAULT_ABI
+ if getattr(T.TO, 'ABI', FFI_DEFAULT_ABI) == FFI_STDCALL:
+ # for win32 system call
+ functype = ctypes.WINFUNCTYPE
argtypes = [get_ctypes_type(ARG) for ARG in T.TO.ARGS
if ARG is not lltype.Void]
if T.TO.RESULT is lltype.Void:
@@ -366,10 +373,10 @@
restype = get_ctypes_type(T.TO.RESULT)
try:
kwds = {'use_errno': True}
- return ctypes.CFUNCTYPE(restype, *argtypes, **kwds)
+ return functype(restype, *argtypes, **kwds)
except TypeError:
# unexpected 'use_errno' argument, old ctypes version
- return ctypes.CFUNCTYPE(restype, *argtypes)
+ return functype(restype, *argtypes)
elif isinstance(T.TO, lltype.OpaqueType):
return ctypes.c_void_p
else:
diff --git a/rpython/rtyper/lltypesystem/lltype.py
b/rpython/rtyper/lltypesystem/lltype.py
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -537,7 +537,7 @@
class FuncType(ContainerType):
_gckind = 'raw'
__name__ = 'func'
- def __init__(self, args, result):
+ def __init__(self, args, result, abi='FFI_DEFAULT_ABI'):
for arg in args:
assert isinstance(arg, LowLevelType)
# There are external C functions eating raw structures, not
@@ -547,6 +547,7 @@
if isinstance(result, ContainerType):
raise TypeError, "function result can only be primitive or pointer"
self.RESULT = result
+ self.ABI = abi
def __str__(self):
args = ', '.join(map(str, self.ARGS))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit