[pypy-commit] pypy matrixmath-dot: Merge with default

mattip noreply at buildbot.pypy.org
Mon Dec 5 22:42:04 CET 2011


Author: mattip
Branch: matrixmath-dot
Changeset: r50185:55693d8b2b89
Date: 2011-12-04 21:49 +0200
http://bitbucket.org/pypy/pypy/changeset/55693d8b2b89/

Log:	Merge with default

diff --git a/lib_pypy/_sha.py b/lib_pypy/_sha.py
--- a/lib_pypy/_sha.py
+++ b/lib_pypy/_sha.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-# -*- coding: iso-8859-1
+# -*- coding: iso-8859-1 -*-
 
 # Note that PyPy contains also a built-in module 'sha' which will hide
 # this one if compiled in.
diff --git a/lib_pypy/itertools.py b/lib_pypy/itertools.py
--- a/lib_pypy/itertools.py
+++ b/lib_pypy/itertools.py
@@ -25,7 +25,7 @@
 
 __all__ = ['chain', 'count', 'cycle', 'dropwhile', 'groupby', 'ifilter',
            'ifilterfalse', 'imap', 'islice', 'izip', 'repeat', 'starmap',
-           'takewhile', 'tee']
+           'takewhile', 'tee', 'compress', 'product']
 
 try: from __pypy__ import builtinify
 except ImportError: builtinify = lambda f: f
diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -67,10 +67,7 @@
         if self.unicodedata_handler:
             return self.unicodedata_handler
         try:
-            w_builtin = space.getbuiltinmodule('__builtin__')
-            w_import = space.getattr(w_builtin, space.wrap("__import__"))
-            w_unicodedata = space.call_function(w_import,
-                                                space.wrap("unicodedata"))
+            w_unicodedata = space.getbuiltinmodule("unicodedata")
             w_getcode = space.getattr(w_unicodedata, space.wrap("_get_code"))
         except OperationError:
             return None
diff --git a/pypy/module/_multiprocessing/interp_connection.py b/pypy/module/_multiprocessing/interp_connection.py
--- a/pypy/module/_multiprocessing/interp_connection.py
+++ b/pypy/module/_multiprocessing/interp_connection.py
@@ -100,7 +100,6 @@
 
         res, newbuf = self.do_recv_string(
             space, self.BUFFER_SIZE, maxlength)
-        res = intmask(res) # XXX why?
         try:
             if newbuf:
                 return space.wrap(rffi.charpsize2str(newbuf, res))
@@ -117,7 +116,6 @@
 
         res, newbuf = self.do_recv_string(
             space, length - offset, PY_SSIZE_T_MAX)
-        res = intmask(res) # XXX why?
         try:
             if newbuf:
                 raise BufferTooShort(space, space.wrap(
@@ -148,7 +146,6 @@
 
         res, newbuf = self.do_recv_string(
             space, self.BUFFER_SIZE, PY_SSIZE_T_MAX)
-        res = intmask(res) # XXX why?
         try:
             if newbuf:
                 w_received = space.wrap(rffi.charpsize2str(newbuf, res))
@@ -413,7 +410,7 @@
                                self.buffer, min(self.BUFFER_SIZE, buflength),
                                read_ptr, rffi.NULL)
             if result:
-                return read_ptr[0], lltype.nullptr(rffi.CCHARP.TO)
+                return intmask(read_ptr[0]), lltype.nullptr(rffi.CCHARP.TO)
 
             err = rwin32.GetLastError()
             if err == ERROR_BROKEN_PIPE:
@@ -476,7 +473,7 @@
         block = timeout < 0
         if not block:
             # XXX does not check for overflow
-            deadline = _GetTickCount() + int(1000 * timeout + 0.5)
+            deadline = intmask(_GetTickCount()) + int(1000 * timeout + 0.5)
         else:
             deadline = 0
 
@@ -500,7 +497,7 @@
                 return True
 
             if not block:
-                now = _GetTickCount()
+                now = intmask(_GetTickCount())
                 if now > deadline:
                     return False
                 diff = deadline - now
diff --git a/pypy/module/_multiprocessing/interp_semaphore.py b/pypy/module/_multiprocessing/interp_semaphore.py
--- a/pypy/module/_multiprocessing/interp_semaphore.py
+++ b/pypy/module/_multiprocessing/interp_semaphore.py
@@ -235,7 +235,7 @@
             elif timeout >= 0.5 * rwin32.INFINITE: # 25 days
                 raise OperationError(space.w_OverflowError,
                                      space.wrap("timeout is too large"))
-            full_msecs = int(timeout + 0.5)
+            full_msecs = r_uint(int(timeout + 0.5))
 
         # check whether we can acquire without blocking
         res = rwin32.WaitForSingleObject(self.handle, 0)
@@ -243,7 +243,7 @@
         if res != rwin32.WAIT_TIMEOUT:
             return True
 
-        msecs = r_uint(full_msecs)
+        msecs = full_msecs
         start = _GetTickCount()
 
         while True:
@@ -269,7 +269,7 @@
                 ticks = _GetTickCount()
                 if r_uint(ticks - start) >= full_msecs:
                     return False
-                msecs = r_uint(full_msecs - (ticks - start))
+                msecs = full_msecs - r_uint(ticks - start)
 
         # handle result
         if res != rwin32.WAIT_TIMEOUT:
diff --git a/pypy/module/_rawffi/interp_rawffi.py b/pypy/module/_rawffi/interp_rawffi.py
--- a/pypy/module/_rawffi/interp_rawffi.py
+++ b/pypy/module/_rawffi/interp_rawffi.py
@@ -543,6 +543,7 @@
     from pypy.rlib.rwin32 import GetLastError
     return space.wrap(GetLastError())
 
-def set_last_error(space, w_error):
+ at unwrap_spec(error=int)
+def set_last_error(space, error):
     from pypy.rlib.rwin32 import SetLastError
-    SetLastError(space.uint_w(w_error))
+    SetLastError(error)
diff --git a/pypy/rlib/_rsocket_rffi.py b/pypy/rlib/_rsocket_rffi.py
--- a/pypy/rlib/_rsocket_rffi.py
+++ b/pypy/rlib/_rsocket_rffi.py
@@ -418,7 +418,7 @@
 if _MSVC:
     def invalid_socket(fd):
         return fd == INVALID_SOCKET
-    INVALID_SOCKET = cConfig.INVALID_SOCKET
+    INVALID_SOCKET = intmask(cConfig.INVALID_SOCKET)
 else:
     def invalid_socket(fd):
         return fd < 0
diff --git a/pypy/rlib/rwin32.py b/pypy/rlib/rwin32.py
--- a/pypy/rlib/rwin32.py
+++ b/pypy/rlib/rwin32.py
@@ -98,8 +98,13 @@
     INVALID_HANDLE_VALUE = rffi.cast(HANDLE, -1)
     PFILETIME = rffi.CArrayPtr(FILETIME)
 
-    GetLastError = winexternal('GetLastError', [], DWORD, threadsafe=False)
-    SetLastError = winexternal('SetLastError', [DWORD], lltype.Void)
+    _GetLastError = winexternal('GetLastError', [], DWORD, threadsafe=False)
+    _SetLastError = winexternal('SetLastError', [DWORD], lltype.Void)
+
+    def GetLastError():
+        return rffi.cast(lltype.Signed, _GetLastError())
+    def SetLastError(err):
+        _SetLastError(rffi.cast(DWORD, err))
 
     # In tests, the first call to GetLastError is always wrong, because error
     # is hidden by operations in ll2ctypes.  Call it now.
@@ -184,12 +189,12 @@
             msglen = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                                    FORMAT_MESSAGE_FROM_SYSTEM,
                                    None,
-                                   code,
+                                   rffi.cast(DWORD, code),
                                    DEFAULT_LANGUAGE,
                                    rffi.cast(rffi.CCHARP, buf),
                                    0, None)
 
-            if msglen <= 2 or msglen > sys.maxint:
+            if msglen <= 2:   # includes the case msglen < 0
                 return fake_FormatError(code)
 
             # FormatMessage always appends \r\n.
diff --git a/pypy/rpython/module/ll_os.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -1773,7 +1773,7 @@
 
         @registering(rwin32.FormatError)
         def register_rwin32_FormatError(self):
-            return extdef([rwin32.DWORD], str,
+            return extdef([lltype.Signed], str,
                           "rwin32_FormatError",
                           llimpl=rwin32.llimpl_FormatError,
                           ooimpl=rwin32.fake_FormatError)
diff --git a/pypy/rpython/module/ll_os_stat.py b/pypy/rpython/module/ll_os_stat.py
--- a/pypy/rpython/module/ll_os_stat.py
+++ b/pypy/rpython/module/ll_os_stat.py
@@ -12,6 +12,7 @@
 from pypy.rpython.tool import rffi_platform as platform
 from pypy.rpython.lltypesystem.rtupletype import TUPLE_TYPE
 from pypy.rlib import rposix
+from pypy.rlib.rarithmetic import intmask
 from pypy.rlib.objectmodel import specialize
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.rpython.annlowlevel import hlstr
@@ -442,20 +443,19 @@
 # Helper functions for win32
 
 def make_longlong(high, low):
-    return (lltype.r_longlong(high) << 32) + lltype.r_longlong(low)
+    return (rffi.r_longlong(high) << 32) + rffi.r_longlong(low)
 
 # Seconds between 1.1.1601 and 1.1.1970
-secs_between_epochs = lltype.r_longlong(11644473600)
+secs_between_epochs = rffi.r_longlong(11644473600)
 
 def FILE_TIME_to_time_t_nsec(filetime):
     ft = make_longlong(filetime.c_dwHighDateTime, filetime.c_dwLowDateTime)
     # FILETIME is in units of 100 nsec
     nsec = (ft % 10000000) * 100
     time = (ft / 10000000) - secs_between_epochs
-    return time, nsec
+    return intmask(time), intmask(nsec)
 
 def time_t_to_FILE_TIME(time, filetime):
-    ft = lltype.r_longlong((time + secs_between_epochs) * 10000000)
-    filetime.c_dwHighDateTime = lltype.r_uint(ft >> 32)
-    filetime.c_dwLowDateTime = lltype.r_uint(ft & lltype.r_uint(-1))
-
+    ft = (rffi.r_longlong(time) + secs_between_epochs) * 10000000
+    filetime.c_dwHighDateTime = rffi.r_uint(ft >> 32)
+    filetime.c_dwLowDateTime = rffi.r_uint(ft)    # masking off high bits


More information about the pypy-commit mailing list