1. Pypy
  2. Untitled project
  3. pypy

Commits

Ronan Lamy  committed 25e171c Merge

hg merge default

  • Participants
  • Parent commits 2e89f6d, a82f83c
  • Branches less-stringly-ops

Comments (0)

Files changed (134)

File lib-python/2.7/argparse.py

View file
  • Ignore whitespace
             # error if this argument is not allowed with other previously
             # seen arguments, assuming that actions that use the default
             # value don't really count as "present"
-            if argument_values is not action.default:
+
+            # XXX PyPy bug-to-bug compatibility: "is" on primitive types
+            # is not consistent in CPython.  We'll assume it is close
+            # enough for ints (which is true only for "small ints"), but
+            # for floats and longs and complexes we'll go for the option
+            # of forcing "is" to say False, like it usually does on
+            # CPython.  A fix is pending on CPython trunk
+            # (http://bugs.python.org/issue18943) but that might change
+            # the details of the semantics and so not be applied to 2.7.
+            # See the line AA below.
+
+            if (argument_values is not action.default or
+                    type(argument_values) in (float, long, complex)):  # AA
                 seen_non_default_actions.add(action)
                 for conflict_action in action_conflicts.get(action, []):
                     if conflict_action in seen_non_default_actions:

File lib-python/2.7/uuid.py

View file
  • Ignore whitespace
         """
 
         if hex is not None:
-            if (bytes is not None or bytes_le is not None or fields is not None
-                    or int is not None):
-                raise TypeError('if the hex argument is given, bytes, bytes_le, fields,'
-                                ' and int need to be None')
+            if (bytes is not None or bytes_le is not None or
+                    fields is not None or int is not None):
+                raise TypeError('if the hex argument is given, bytes,'
+                                ' bytes_le, fields,  and int need to be None')
             hex = hex.replace('urn:', '').replace('uuid:', '')
             hex = hex.strip('{}').replace('-', '')
             if len(hex) != 32:
             int = long(hex, 16)
         elif bytes_le is not None:
             if bytes is not None or fields is not None or int is not None:
-                raise TypeError('if the bytes_le argument is given, bytes, fields,'
-                                ' and int need to be None')
+                raise TypeError('if the bytes_le argument is given, bytes,'
+                                ' fields, and int need to be None')
             if len(bytes_le) != 16:
                 raise ValueError('bytes_le is not a 16-char string')
             bytes = (bytes_le[3] + bytes_le[2] + bytes_le[1] + bytes_le[0] +
                    struct.unpack('>Q', bytes[8:])[0])
         elif bytes is not None:
             if fields is not None or int is not None:
-                raise TypeError('if the bytes argument is given, fields'
-                                ' and int need to be None')
+                raise TypeError('if the bytes argument is given, fields '
+                                'and int need to be None')
             if len(bytes) != 16:
                 raise ValueError('bytes is not a 16-char string')
             int = (struct.unpack('>Q', bytes[:8])[0] << 64 |
                    struct.unpack('>Q', bytes[8:])[0])
         elif fields is not None:
             if int is not None:
-                raise TypeError('if the fields argument is given, int needs to be None')
+                raise TypeError('if the fields argument is given, int needs'
+                                ' to be None')
             if len(fields) != 6:
                 raise ValueError('fields is not a 6-tuple')
             (time_low, time_mid, time_hi_version,

File lib_pypy/_curses.py

View file
  • Ignore whitespace
 """Reimplementation of the standard extension module '_curses' using cffi."""
 
 import sys
+if sys.platform == 'win32':
+    #This module does not exist in windows
+    raise ImportError('No module named _curses')
 from functools import wraps
 
 from cffi import FFI

File lib_pypy/_tkinter/__init__.py

View file
  • Ignore whitespace
 READABLE = tklib.TCL_READABLE
 WRITABLE = tklib.TCL_WRITABLE
 EXCEPTION = tklib.TCL_EXCEPTION
+DONT_WAIT = tklib.TCL_DONT_WAIT
 
 def create(screenName=None, baseName=None, className=None,
            interactive=False, wantobjects=False, wantTk=True,

File lib_pypy/_tkinter/app.py

View file
  • Ignore whitespace
 from . import TclError
 from .tclobj import TclObject, FromObj, AsObj, TypeCache
 
+import contextlib
 import sys
+import threading
+import time
+
+
+class _DummyLock(object):
+    "A lock-like object that does not do anything"
+    def acquire(self):
+        pass
+    def release(self):
+        pass
+    def __enter__(self):
+        pass
+    def __exit__(self, *exc):
+        pass
+
 
 def varname_converter(input):
     if isinstance(input, TclObject):
     def PythonCmd(clientData, interp, argc, argv):
         self = tkffi.from_handle(clientData)
         assert self.app.interp == interp
-        try:
-            args = [tkffi.string(arg) for arg in argv[1:argc]]
-            result = self.func(*args)
-            obj = AsObj(result)
-            tklib.Tcl_SetObjResult(interp, obj)
-        except:
-            self.app.errorInCmd = True
-            self.app.exc_info = sys.exc_info()
-            return tklib.TCL_ERROR
-        else:
-            return tklib.TCL_OK
+        with self.app._tcl_lock_released():
+            try:
+                args = [tkffi.string(arg) for arg in argv[1:argc]]
+                result = self.func(*args)
+                obj = AsObj(result)
+                tklib.Tcl_SetObjResult(interp, obj)
+            except:
+                self.app.errorInCmd = True
+                self.app.exc_info = sys.exc_info()
+                return tklib.TCL_ERROR
+            else:
+                return tklib.TCL_OK
 
     @tkffi.callback("Tcl_CmdDeleteProc")
     def PythonCmdDelete(clientData):
 
 
 class TkApp(object):
+    _busywaitinterval = 0.02  # 20ms.
+
     def __new__(cls, screenName, baseName, className,
                 interactive, wantobjects, wantTk, sync, use):
         if not wantobjects:
         self.quitMainLoop = False
         self.errorInCmd = False
 
+        if not self.threaded:
+            # TCL is not thread-safe, calls needs to be serialized.
+            self._tcl_lock = threading.Lock()
+        else:
+            self._tcl_lock = _DummyLock()
+
         self._typeCache = TypeCache()
         self._commands = {}
 
         if self.threaded and self.thread_id != tklib.Tcl_GetCurrentThread():
             raise RuntimeError("Calling Tcl from different appartment")
 
+    @contextlib.contextmanager
+    def _tcl_lock_released(self):
+        "Context manager to temporarily release the tcl lock."
+        self._tcl_lock.release()
+        yield
+        self._tcl_lock.acquire()
+
     def loadtk(self):
         # We want to guard against calling Tk_Init() multiple times
         err = tklib.Tcl_Eval(self.interp, "info exists     tk_version")
         flags=tklib.TCL_LEAVE_ERR_MSG
         if global_only:
             flags |= tklib.TCL_GLOBAL_ONLY
-        res = tklib.Tcl_GetVar2Ex(self.interp, name1, name2, flags)
-        if not res:
-            self.raiseTclError()
-        assert self._wantobjects
-        return FromObj(self, res)
+        with self._tcl_lock:
+            res = tklib.Tcl_GetVar2Ex(self.interp, name1, name2, flags)
+            if not res:
+                self.raiseTclError()
+            assert self._wantobjects
+            return FromObj(self, res)
 
     def _setvar(self, name1, value, global_only=False):
         name1 = varname_converter(name1)
+        # XXX Acquire tcl lock???
         newval = AsObj(value)
         flags=tklib.TCL_LEAVE_ERR_MSG
         if global_only:
             flags |= tklib.TCL_GLOBAL_ONLY
-        res = tklib.Tcl_SetVar2Ex(self.interp, name1, tkffi.NULL,
-                                  newval, flags)
-        if not res:
-            self.raiseTclError()
+        with self._tcl_lock:
+            res = tklib.Tcl_SetVar2Ex(self.interp, name1, tkffi.NULL,
+                                      newval, flags)
+            if not res:
+                self.raiseTclError()
 
     def _unsetvar(self, name1, name2=None, global_only=False):
         name1 = varname_converter(name1)
         flags=tklib.TCL_LEAVE_ERR_MSG
         if global_only:
             flags |= tklib.TCL_GLOBAL_ONLY
-        res = tklib.Tcl_UnsetVar2(self.interp, name1, name2, flags)
-        if res == tklib.TCL_ERROR:
-            self.raiseTclError()
+        with self._tcl_lock:
+            res = tklib.Tcl_UnsetVar2(self.interp, name1, name2, flags)
+            if res == tklib.TCL_ERROR:
+                self.raiseTclError()
 
     def getvar(self, name1, name2=None):
         return self._var_invoke(self._getvar, name1, name2)
         if self.threaded and self.thread_id != tklib.Tcl_GetCurrentThread():
             raise NotImplementedError("Call from another thread")
 
-        res = tklib.Tcl_CreateCommand(
-            self.interp, cmdName, _CommandData.PythonCmd,
-            clientData, _CommandData.PythonCmdDelete)
+        with self._tcl_lock:
+            res = tklib.Tcl_CreateCommand(
+                self.interp, cmdName, _CommandData.PythonCmd,
+                clientData, _CommandData.PythonCmdDelete)
         if not res:
             raise TclError("can't create Tcl command")
 
         if self.threaded and self.thread_id != tklib.Tcl_GetCurrentThread():
             raise NotImplementedError("Call from another thread")
 
-        res = tklib.Tcl_DeleteCommand(self.interp, cmdName)
+        with self._tcl_lock:
+            res = tklib.Tcl_DeleteCommand(self.interp, cmdName)
         if res == -1:
             raise TclError("can't delete Tcl command")
 
                 tklib.Tcl_IncrRefCount(obj)
                 objects[i] = obj
 
-            res = tklib.Tcl_EvalObjv(self.interp, argc, objects, flags)
-            if res == tklib.TCL_ERROR:
-                self.raiseTclError()
-            else:
-                result = self._callResult()
+            with self._tcl_lock:
+                res = tklib.Tcl_EvalObjv(self.interp, argc, objects, flags)
+                if res == tklib.TCL_ERROR:
+                    self.raiseTclError()
+                else:
+                    result = self._callResult()
         finally:
             for obj in objects:
                 if obj:
 
     def eval(self, script):
         self._check_tcl_appartment()
-        res = tklib.Tcl_Eval(self.interp, script)
-        if res == tklib.TCL_ERROR:
-            self.raiseTclError()
-        return tkffi.string(tklib.Tcl_GetStringResult(self.interp))
+        with self._tcl_lock:
+            res = tklib.Tcl_Eval(self.interp, script)
+            if res == tklib.TCL_ERROR:
+                self.raiseTclError()
+            return tkffi.string(tklib.Tcl_GetStringResult(self.interp))
 
     def evalfile(self, filename):
         self._check_tcl_appartment()
-        res = tklib.Tcl_EvalFile(self.interp, filename)
-        if res == tklib.TCL_ERROR:
-            self.raiseTclError()
-        return tkffi.string(tklib.Tcl_GetStringResult(self.interp))
+        with self._tcl_lock:
+            res = tklib.Tcl_EvalFile(self.interp, filename)
+            if res == tklib.TCL_ERROR:
+                self.raiseTclError()
+            return tkffi.string(tklib.Tcl_GetStringResult(self.interp))
 
     def split(self, arg):
         if isinstance(arg, tuple):
             if self.threaded:
                 result = tklib.Tcl_DoOneEvent(0)
             else:
-                raise NotImplementedError("TCL configured without threads")
+                with self._tcl_lock:
+                    result = tklib.Tcl_DoOneEvent(tklib.TCL_DONT_WAIT)
+                if result == 0:
+                    time.sleep(self._busywaitinterval)
 
             if result < 0:
                 break

File lib_pypy/_tkinter/tklib.py

View file
  • Ignore whitespace
 # C bindings with libtcl and libtk.
 
 from cffi import FFI
+import sys
 
 tkffi = FFI()
 
 #define TCL_EVAL_DIRECT ...
 #define TCL_EVAL_GLOBAL ...
 
+#define TCL_DONT_WAIT ...
+
 typedef unsigned short Tcl_UniChar;
 typedef ... Tcl_Interp;
 typedef ...* Tcl_ThreadId;
 int Tk_GetNumMainWindows();
 """)
 
+# XXX find a better way to detect paths
+# XXX pick up CPPFLAGS and LDFLAGS and add to these paths?
+if sys.platform.startswith("openbsd"):
+    incdirs = ['/usr/local/include/tcl8.5', '/usr/local/include/tk8.5', '/usr/X11R6/include']
+    linklibs = ['tk85', 'tcl85']
+    libdirs = ['/usr/local/lib', '/usr/X11R6/lib']
+else:
+    incdirs=['/usr/include/tcl']
+    linklibs=['tcl', 'tk']
+    libdirs = []
+
 tklib = tkffi.verify("""
 #include <tcl.h>
 #include <tk.h>
 char *get_tk_version() { return TK_VERSION; }
 char *get_tcl_version() { return TCL_VERSION; }
 """,
-include_dirs=['/usr/include/tcl'],
-libraries=['tcl', 'tk'],
+include_dirs=incdirs,
+libraries=linklibs,
+library_dirs = libdirs
 )

File lib_pypy/cffi/__init__.py

View file
  • Ignore whitespace
 from .api import FFI, CDefError, FFIError
 from .ffiplatform import VerificationError, VerificationMissing
 
-__version__ = "0.7"
-__version_info__ = (0, 7)
+__version__ = "0.7.2"
+__version_info__ = (0, 7, 2)

File lib_pypy/cffi/api.py

View file
  • Ignore whitespace
             # _cffi_backend.so compiled.
             import _cffi_backend as backend
             from . import __version__
-            assert backend.__version__ == __version__
+            assert (backend.__version__ == __version__ or
+                    backend.__version__ == __version__[:3])
             # (If you insist you can also try to pass the option
             # 'backend=backend_ctypes.CTypesBackend()', but don't
             # rely on it!  It's probably not going to work well.)

File lib_pypy/cffi/commontypes.py

View file
  • Ignore whitespace
         elif result in model.PrimitiveType.ALL_PRIMITIVE_TYPES:
             result = model.PrimitiveType(result)
         else:
-            assert commontype != result
+            if commontype == result:
+                raise api.FFIError("Unsupported type: %r.  Please file a bug "
+                                   "if you think it should be." % (commontype,))
             result = resolve_common_type(result)   # recursively
         assert isinstance(result, model.BaseTypeByIdentity)
         _CACHE[commontype] = result

File lib_pypy/cffi/cparser.py

View file
  • Ignore whitespace
                 # assume a primitive type.  get it from .names, but reduce
                 # synonyms to a single chosen combination
                 names = list(type.names)
-                if names == ['signed'] or names == ['unsigned']:
-                    names.append('int')
-                if names[0] == 'signed' and names != ['signed', 'char']:
-                    names.pop(0)
-                if (len(names) > 1 and names[-1] == 'int'
-                        and names != ['unsigned', 'int']):
-                    names.pop()
+                if names != ['signed', 'char']:    # keep this unmodified
+                    prefixes = {}
+                    while names:
+                        name = names[0]
+                        if name in ('short', 'long', 'signed', 'unsigned'):
+                            prefixes[name] = prefixes.get(name, 0) + 1
+                            del names[0]
+                        else:
+                            break
+                    # ignore the 'signed' prefix below, and reorder the others
+                    newnames = []
+                    for prefix in ('unsigned', 'short', 'long'):
+                        for i in range(prefixes.get(prefix, 0)):
+                            newnames.append(prefix)
+                    if not names:
+                        names = ['int']    # implicitly
+                    if names == ['int']:   # but kill it if 'short' or 'long'
+                        if 'short' in prefixes or 'long' in prefixes:
+                            names = []
+                    names = newnames + names
                 ident = ' '.join(names)
                 if ident == 'void':
                     return model.void_type
                 self._partial_length = True
                 return None
         #
-        raise api.FFIError("unsupported non-constant or "
-                           "not immediately constant expression")
+        raise api.FFIError("unsupported expression: expected a "
+                           "simple numeric constant")
 
     def _build_enum_type(self, explicit_name, decls):
         if decls is not None:

File lib_pypy/cffi/vengine_gen.py

View file
  • Ignore whitespace
     def load_library(self):
         # import it with the CFFI backend
         backend = self.ffi._backend
-        module = backend.load_library(self.verifier.modulefilename)
+        # needs to make a path that contains '/', on Posix
+        filename = os.path.join(os.curdir, self.verifier.modulefilename)
+        module = backend.load_library(filename)
         #
         # call loading_gen_struct() to get the struct layout inferred by
         # the C compiler

File pypy/doc/faq.rst

View file
  • Ignore whitespace
   attempt to point newcomers at existing alternatives, which are more
   mainstream and where they will get help from many people.*
 
-  *If anybody seriously wants to promote RPython anyway, he is welcome
+  *If anybody seriously wants to promote RPython anyway, they are welcome
   to: we won't actively resist such a plan.  There are a lot of things
   that could be done to make RPython a better Java-ish language for
   example, starting with supporting non-GIL-based multithreading, but we
 patch the generated machine code.
 
 So the position of the core PyPy developers is that if anyone wants to
-make an N+1'th attempt with LLVM, he is welcome, and he will receive a
-bit of help on the IRC channel, but he is left with the burden of proof
+make an N+1'th attempt with LLVM, they are welcome, and will be happy to
+provide help in the IRC channel, but they are left with the burden of proof
 that it works.
 
 ----------------------

File pypy/doc/whatsnew-head.rst

View file
  • Ignore whitespace
 .. branch: reflex-support
 .. branch: numpypy-inplace-op
 .. branch: rewritten-loop-logging
+.. branch: no-release-gil
+.. branch: safe-win-mmap
+.. branch: boolean-indexing-cleanup
 
 .. branch: nobold-backtrace
 Work on improving UnionError messages and stack trace displays.

File pypy/interpreter/baseobjspace.py

View file
  • Ignore whitespace
         raise NotImplementedError("only for interp-level user subclasses "
                                   "from typedef.py")
 
-    def getname(self, space, default='?'):
+    def getname(self, space):
         try:
             return space.str_w(space.getattr(self, space.wrap('__name__')))
         except OperationError, e:
             if e.match(space, space.w_TypeError) or e.match(space, space.w_AttributeError):
-                return default
+                return '?'
             raise
 
     def getaddrstring(self, space):

File pypy/interpreter/function.py

View file
  • Ignore whitespace
                 space.abstract_isinstance_w(w_firstarg, self.w_class)):
             pass  # ok
         else:
-            clsdescr = self.w_class.getname(space, "")
-            if clsdescr:
+            clsdescr = self.w_class.getname(space)
+            if clsdescr and clsdescr != '?':
                 clsdescr += " instance"
             else:
                 clsdescr = "instance"
             if w_firstarg is None:
                 instdescr = "nothing"
             else:
-                instname = space.abstract_getclass(w_firstarg).getname(space,
-                                                                       "")
-                if instname:
+                instname = space.abstract_getclass(w_firstarg).getname(space)
+                if instname and instname != '?':
                     instdescr = instname + " instance"
                 else:
                     instdescr = "instance"

File pypy/interpreter/test/test_argument.py

View file
  • Ignore whitespace
 
     def type(self, obj):
         class Type:
-            def getname(self, space, default='?'):
+            def getname(self, space):
                 return type(obj).__name__
         return Type()
 

File pypy/module/__pypy__/interp_time.py

View file
  • Ignore whitespace
 
     c_clock_gettime = rffi.llexternal("clock_gettime",
         [lltype.Signed, lltype.Ptr(TIMESPEC)], rffi.INT,
-        compilation_info=CConfig._compilation_info_, threadsafe=False
+        compilation_info=CConfig._compilation_info_, releasegil=False
     )
     c_clock_getres = rffi.llexternal("clock_getres",
         [lltype.Signed, lltype.Ptr(TIMESPEC)], rffi.INT,
-        compilation_info=CConfig._compilation_info_, threadsafe=False
+        compilation_info=CConfig._compilation_info_, releasegil=False
     )
 
     @unwrap_spec(clk_id="c_int")

File pypy/module/_cffi_backend/ccallback.py

View file
  • Ignore whitespace
         if rffi.cast(lltype.Signed, res) != clibffi.FFI_OK:
             raise OperationError(space.w_SystemError,
                 space.wrap("libffi failed to build this callback"))
+        #
+        # We must setup the GIL here, in case the callback is invoked in
+        # some other non-Pythonic thread.  This is the same as cffi on
+        # CPython.
+        if space.config.translation.thread:
+            from pypy.module.thread.os_thread import setup_threads
+            setup_threads(space)
 
     def get_closure(self):
         return rffi.cast(clibffi.FFI_CLOSUREP, self._cdata)

File pypy/module/_minimal_curses/fficurses.py

View file
  • Ignore whitespace
 def try_ldflags():
     yield ExternalCompilationInfo(libraries=['curses'])
     yield ExternalCompilationInfo(libraries=['curses', 'tinfo'])
+    yield ExternalCompilationInfo(libraries=['ncurses'])
+    yield ExternalCompilationInfo(libraries=['ncurses'],
+                                  library_dirs=['/usr/lib64'])
 
 def try_tools():
     try:

File pypy/module/_multiprocessing/interp_semaphore.py

View file
  • Ignore whitespace
         'CreateSemaphoreA', [rffi.VOIDP, rffi.LONG, rffi.LONG, rwin32.LPCSTR],
         rwin32.HANDLE)
     _CloseHandle = rwin32.winexternal('CloseHandle', [rwin32.HANDLE],
-        rwin32.BOOL, threadsafe=False)
+        rwin32.BOOL, releasegil=False)
     _ReleaseSemaphore = rwin32.winexternal(
         'ReleaseSemaphore', [rwin32.HANDLE, rffi.LONG, rffi.LONGP],
         rwin32.BOOL)
     _sem_open = external('sem_open',
                          [rffi.CCHARP, rffi.INT, rffi.INT, rffi.UINT],
                          SEM_T)
-    # tread sem_close as not threadsafe for now to be able to use the __del__
-    _sem_close = external('sem_close', [SEM_T], rffi.INT, threadsafe=False)
+    # sem_close is releasegil=False to be able to use it in the __del__
+    _sem_close = external('sem_close', [SEM_T], rffi.INT, releasegil=False)
     _sem_unlink = external('sem_unlink', [rffi.CCHARP], rffi.INT)
     _sem_wait = external('sem_wait', [SEM_T], rffi.INT)
     _sem_trywait = external('sem_trywait', [SEM_T], rffi.INT)

File pypy/module/_pypyjson/test/test__pypyjson.py

View file
  • Ignore whitespace
 # -*- encoding: utf-8 -*-
-import py
+import py, sys
 from pypy.module._pypyjson.interp_decoder import JSONDecoder
 
 def test_skip_whitespace():
 class AppTest(object):
     spaceconfig = {"objspace.usemodules._pypyjson": True}
 
+    def setup_class(cls):
+        cls.w_run_on_16bit = cls.space.wrap(sys.maxunicode == 65535)
+
     def test_raise_on_unicode(self):
         import _pypyjson
         raises(TypeError, _pypyjson.loads, u"42")
         raises(ValueError, "_pypyjson.loads('[1: 2]')")
         raises(ValueError, "_pypyjson.loads('[1, 2')")
         raises(ValueError, """_pypyjson.loads('["extra comma",]')""")
-        
+
     def test_unicode_surrogate_pair(self):
+        if self.run_on_16bit:
+            skip("XXX fix me or mark definitely skipped")
         import _pypyjson
         expected = u'z\U0001d120x'
         res = _pypyjson.loads('"z\\ud834\\udd20x"')
         assert res == expected
-
-

File pypy/module/_weakref/interp__weakref.py

View file
  • Ignore whitespace
             state = '; dead'
         else:
             typename = space.type(w_obj).getname(space)
-            objname = w_obj.getname(space, '')
-            if objname:
+            objname = w_obj.getname(space)
+            if objname and objname != '?':
                 state = "; to '%s' (%s)" % (typename, objname)
             else:
                 state = "; to '%s'" % (typename,)

File pypy/module/bz2/interp_bz2.py

View file
  • Ignore whitespace
 BZ2_bzCompressInit = external('BZ2_bzCompressInit', [bz_stream, rffi.INT,
                               rffi.INT, rffi.INT], rffi.INT)
 BZ2_bzCompressEnd = external('BZ2_bzCompressEnd', [bz_stream], rffi.INT,
-                             threadsafe=False)
+                             releasegil=False)
 BZ2_bzCompress = external('BZ2_bzCompress', [bz_stream, rffi.INT], rffi.INT)
 BZ2_bzDecompressInit = external('BZ2_bzDecompressInit', [bz_stream, rffi.INT,
                                                          rffi.INT], rffi.INT)
 BZ2_bzDecompressEnd = external('BZ2_bzDecompressEnd', [bz_stream], rffi.INT,
-                               threadsafe=False)
+                               releasegil=False)
 BZ2_bzDecompress = external('BZ2_bzDecompress', [bz_stream], rffi.INT)
 
 def _catch_bz2_error(space, bzerror):

File pypy/module/cppyy/capi/builtin_capi.py

View file
  • Ignore whitespace
 _c_num_scopes = rffi.llexternal(
     "cppyy_num_scopes",
     [C_SCOPE], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_num_scopes(space, cppscope):
     return _c_num_scopes(cppscope.handle)
 _c_resolve_name = rffi.llexternal(
     "cppyy_resolve_name",
     [rffi.CCHARP], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_resolve_name(space, name):
     return charp2str_free(space, _c_resolve_name(name))
 _c_get_scope_opaque = rffi.llexternal(
     "cppyy_get_scope",
     [rffi.CCHARP], C_SCOPE,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_get_scope_opaque(space, name):
     return _c_get_scope_opaque(name)
 _c_get_template = rffi.llexternal(
     "cppyy_get_template",
     [rffi.CCHARP], C_TYPE,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_get_template(space, name):
     return _c_get_template(name)
 _c_actual_class = rffi.llexternal(
     "cppyy_actual_class",
     [C_TYPE, C_OBJECT], C_TYPE,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_actual_class(space, cppclass, cppobj):
     return _c_actual_class(cppclass.handle, cppobj)
 _c_allocate = rffi.llexternal(
     "cppyy_allocate",
     [C_TYPE], C_OBJECT,
-    threadsafe=ts_memory,
+    releasegil=ts_memory,
     compilation_info=backend.eci)
 def c_allocate(space, cppclass):
     return _c_allocate(cppclass.handle)
 _c_deallocate = rffi.llexternal(
     "cppyy_deallocate",
     [C_TYPE, C_OBJECT], lltype.Void,
-    threadsafe=ts_memory,
+    releasegil=ts_memory,
     compilation_info=backend.eci)
 def c_deallocate(space, cppclass, cppobject):
     _c_deallocate(cppclass.handle, cppobject)
 _c_destruct = rffi.llexternal(
     "cppyy_destruct",
     [C_TYPE, C_OBJECT], lltype.Void,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_destruct(space, cppclass, cppobject):
     _c_destruct(cppclass.handle, cppobject)
 _c_call_v = rffi.llexternal(
     "cppyy_call_v",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], lltype.Void,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_v(space, cppmethod, cppobject, nargs, args):
     _c_call_v(cppmethod, cppobject, nargs, args)
 _c_call_b = rffi.llexternal(
     "cppyy_call_b",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.UCHAR,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_b(space, cppmethod, cppobject, nargs, args):
     return _c_call_b(cppmethod, cppobject, nargs, args)
 _c_call_c = rffi.llexternal(
     "cppyy_call_c",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.CHAR,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_c(space, cppmethod, cppobject, nargs, args):
     return _c_call_c(cppmethod, cppobject, nargs, args)
 _c_call_h = rffi.llexternal(
     "cppyy_call_h",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.SHORT,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_h(space, cppmethod, cppobject, nargs, args):
     return _c_call_h(cppmethod, cppobject, nargs, args)
 _c_call_i = rffi.llexternal(
     "cppyy_call_i",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.INT,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_i(space, cppmethod, cppobject, nargs, args):
     return _c_call_i(cppmethod, cppobject, nargs, args)
 _c_call_l = rffi.llexternal(
     "cppyy_call_l",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.LONG,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_l(space, cppmethod, cppobject, nargs, args):
     return _c_call_l(cppmethod, cppobject, nargs, args)
 _c_call_ll = rffi.llexternal(
     "cppyy_call_ll",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.LONGLONG,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_ll(space, cppmethod, cppobject, nargs, args):
     return _c_call_ll(cppmethod, cppobject, nargs, args)
 _c_call_f = rffi.llexternal(
     "cppyy_call_f",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.FLOAT,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_f(space, cppmethod, cppobject, nargs, args):
     return _c_call_f(cppmethod, cppobject, nargs, args)
 _c_call_d = rffi.llexternal(
     "cppyy_call_d",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.DOUBLE,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_d(space, cppmethod, cppobject, nargs, args):
     return _c_call_d(cppmethod, cppobject, nargs, args)
 _c_call_r = rffi.llexternal(
     "cppyy_call_r",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.VOIDP,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_r(space, cppmethod, cppobject, nargs, args):
     return _c_call_r(cppmethod, cppobject, nargs, args)
 _c_call_s = rffi.llexternal(
     "cppyy_call_s",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP], rffi.CCHARP,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_s(space, cppmethod, cppobject, nargs, args):
     return _c_call_s(cppmethod, cppobject, nargs, args)
 _c_constructor = rffi.llexternal(
     "cppyy_constructor",
     [C_METHOD, C_TYPE, rffi.INT, rffi.VOIDP], C_OBJECT,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_constructor(space, cppmethod, cppobject, nargs, args):
     return _c_constructor(cppmethod, cppobject, nargs, args)
 _c_call_o = rffi.llexternal(
     "cppyy_call_o",
     [C_METHOD, C_OBJECT, rffi.INT, rffi.VOIDP, C_TYPE], rffi.LONG,
-    threadsafe=ts_call,
+    releasegil=ts_call,
     compilation_info=backend.eci)
 def c_call_o(space, method, cppobj, nargs, args, cppclass):
     return _c_call_o(method, cppobj, nargs, args, cppclass.handle)
 _c_get_methptr_getter = rffi.llexternal(
     "cppyy_get_methptr_getter",
     [C_SCOPE, C_INDEX], C_METHPTRGETTER_PTR,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci,
     elidable_function=True)
 def c_get_methptr_getter(space, cppscope, index):
 _c_allocate_function_args = rffi.llexternal(
     "cppyy_allocate_function_args",
     [rffi.SIZE_T], rffi.VOIDP,
-    threadsafe=ts_memory,
+    releasegil=ts_memory,
     compilation_info=backend.eci)
 def c_allocate_function_args(space, size):
     return _c_allocate_function_args(size)
 _c_deallocate_function_args = rffi.llexternal(
     "cppyy_deallocate_function_args",
     [rffi.VOIDP], lltype.Void,
-    threadsafe=ts_memory,
+    releasegil=ts_memory,
     compilation_info=backend.eci)
 def c_deallocate_function_args(space, args):
     _c_deallocate_function_args(args)
 _c_function_arg_sizeof = rffi.llexternal(
     "cppyy_function_arg_sizeof",
     [], rffi.SIZE_T,
-    threadsafe=ts_memory,
+    releasegil=ts_memory,
     compilation_info=backend.eci,
     elidable_function=True)
 def c_function_arg_sizeof(space):
 _c_function_arg_typeoffset = rffi.llexternal(
     "cppyy_function_arg_typeoffset",
     [], rffi.SIZE_T,
-    threadsafe=ts_memory,
+    releasegil=ts_memory,
     compilation_info=backend.eci,
     elidable_function=True)
 def c_function_arg_typeoffset(space):
 _c_is_namespace = rffi.llexternal(
     "cppyy_is_namespace",
     [C_SCOPE], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_is_namespace(space, scope):
     return _c_is_namespace(scope)
 _c_is_enum = rffi.llexternal(
     "cppyy_is_enum",
     [rffi.CCHARP], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_is_enum(space, name):
     return _c_is_enum(name)
 _c_final_name = rffi.llexternal(
     "cppyy_final_name",
     [C_TYPE], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_final_name(space, cpptype):
     return charp2str_free(space, _c_final_name(cpptype))
 _c_scoped_final_name = rffi.llexternal(
     "cppyy_scoped_final_name",
     [C_TYPE], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_scoped_final_name(space, cpptype):
     return charp2str_free(space, _c_scoped_final_name(cpptype))
 _c_has_complex_hierarchy = rffi.llexternal(
     "cppyy_has_complex_hierarchy",
     [C_TYPE], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_has_complex_hierarchy(space, cpptype):
     return _c_has_complex_hierarchy(cpptype)
 _c_num_bases = rffi.llexternal(
     "cppyy_num_bases",
     [C_TYPE], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_num_bases(space, cppclass):
     return _c_num_bases(cppclass.handle)
 _c_base_name = rffi.llexternal(
     "cppyy_base_name",
     [C_TYPE, rffi.INT], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_base_name(space, cppclass, base_index):
     return charp2str_free(space, _c_base_name(cppclass.handle, base_index))
 _c_is_subtype = rffi.llexternal(
     "cppyy_is_subtype",
     [C_TYPE, C_TYPE], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci,
     elidable_function=True)
 @jit.elidable_promote('2')
 _c_base_offset = rffi.llexternal(
     "cppyy_base_offset",
     [C_TYPE, C_TYPE, C_OBJECT, rffi.INT], rffi.SIZE_T,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci,
     elidable_function=True)
 @jit.elidable_promote('1,2,4')
 _c_num_methods = rffi.llexternal(
     "cppyy_num_methods",
     [C_SCOPE], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_num_methods(space, cppscope):
     return _c_num_methods(cppscope.handle)
 _c_method_index_at = rffi.llexternal(
     "cppyy_method_index_at",
     [C_SCOPE, rffi.INT], C_INDEX,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_method_index_at(space, cppscope, imethod):
     return _c_method_index_at(cppscope.handle, imethod)
 _c_method_indices_from_name = rffi.llexternal(
     "cppyy_method_indices_from_name",
     [C_SCOPE, rffi.CCHARP], C_INDEX_ARRAY,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_method_indices_from_name(space, cppscope, name):
     indices = _c_method_indices_from_name(cppscope.handle, name)
 _c_method_name = rffi.llexternal(
     "cppyy_method_name",
     [C_SCOPE, C_INDEX], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_method_name(space, cppscope, index):
     return charp2str_free(space, _c_method_name(cppscope.handle, index))
 _c_method_result_type = rffi.llexternal(
     "cppyy_method_result_type",
     [C_SCOPE, C_INDEX], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_method_result_type(space, cppscope, index):
     return charp2str_free(space, _c_method_result_type(cppscope.handle, index))
 _c_method_num_args = rffi.llexternal(
     "cppyy_method_num_args",
     [C_SCOPE, C_INDEX], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_method_num_args(space, cppscope, index):
     return _c_method_num_args(cppscope.handle, index)
 _c_method_req_args = rffi.llexternal(
     "cppyy_method_req_args",
     [C_SCOPE, C_INDEX], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_method_req_args(space, cppscope, index):
     return _c_method_req_args(cppscope.handle, index)
 _c_method_arg_type = rffi.llexternal(
     "cppyy_method_arg_type",
     [C_SCOPE, C_INDEX, rffi.INT], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_method_arg_type(space, cppscope, index, arg_index):
     return charp2str_free(space, _c_method_arg_type(cppscope.handle, index, arg_index))
 _c_method_arg_default = rffi.llexternal(
     "cppyy_method_arg_default",
     [C_SCOPE, C_INDEX, rffi.INT], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_method_arg_default(space, cppscope, index, arg_index):
     return charp2str_free(space, _c_method_arg_default(cppscope.handle, index, arg_index))
 _c_method_signature = rffi.llexternal(
     "cppyy_method_signature",
     [C_SCOPE, C_INDEX], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_method_signature(space, cppscope, index):
     return charp2str_free(space, _c_method_signature(cppscope.handle, index))
 _c_method_is_template = rffi.llexternal(
     "cppyy_method_is_template",
     [C_SCOPE, C_INDEX], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_method_is_template(space, cppscope, index):
     return _c_method_is_template(cppscope.handle, index)
 _c_method_num_template_args = rffi.llexternal(
     "cppyy_method_num_template_args",
     [C_SCOPE, C_INDEX], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 _c_method_template_arg_name = rffi.llexternal(
     "cppyy_method_template_arg_name",
     [C_SCOPE, C_INDEX, C_INDEX], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_template_args(space, cppscope, index):
     nargs = _c_method_num_template_args(cppscope.handle, index)
 _c_get_method = rffi.llexternal(
     "cppyy_get_method",
     [C_SCOPE, C_INDEX], C_METHOD,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_get_method(space, cppscope, index):
     return _c_get_method(cppscope.handle, index)
 _c_get_global_operator = rffi.llexternal(
     "cppyy_get_global_operator",
     [C_SCOPE, C_SCOPE, C_SCOPE, rffi.CCHARP], WLAVC_INDEX,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_get_global_operator(space, nss, lc, rc, op):
     if nss is not None:
 _c_is_constructor = rffi.llexternal(
     "cppyy_is_constructor",
     [C_TYPE, C_INDEX], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_is_constructor(space, cppclass, index):
     return _c_is_constructor(cppclass.handle, index)
 _c_is_staticmethod = rffi.llexternal(
     "cppyy_is_staticmethod",
     [C_TYPE, C_INDEX], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_is_staticmethod(space, cppclass, index):
     return _c_is_staticmethod(cppclass.handle, index)
 _c_num_datamembers = rffi.llexternal(
     "cppyy_num_datamembers",
     [C_SCOPE], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_num_datamembers(space, cppscope):
     return _c_num_datamembers(cppscope.handle)
 _c_datamember_name = rffi.llexternal(
     "cppyy_datamember_name",
     [C_SCOPE, rffi.INT], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_datamember_name(space, cppscope, datamember_index):
     return charp2str_free(space, _c_datamember_name(cppscope.handle, datamember_index))
 _c_datamember_type = rffi.llexternal(
     "cppyy_datamember_type",
     [C_SCOPE, rffi.INT], rffi.CCHARP,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_datamember_type(space, cppscope, datamember_index):
     return charp2str_free(space, _c_datamember_type(cppscope.handle, datamember_index))
 _c_datamember_offset = rffi.llexternal(
     "cppyy_datamember_offset",
     [C_SCOPE, rffi.INT], rffi.SIZE_T,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_datamember_offset(space, cppscope, datamember_index):
     return _c_datamember_offset(cppscope.handle, datamember_index)
 _c_datamember_index = rffi.llexternal(
     "cppyy_datamember_index",
     [C_SCOPE, rffi.CCHARP], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_datamember_index(space, cppscope, name):
     return _c_datamember_index(cppscope.handle, name)
 _c_is_publicdata = rffi.llexternal(
     "cppyy_is_publicdata",
     [C_SCOPE, rffi.INT], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_is_publicdata(space, cppscope, datamember_index):
     return _c_is_publicdata(cppscope.handle, datamember_index)
 _c_is_staticdata = rffi.llexternal(
     "cppyy_is_staticdata",
     [C_SCOPE, rffi.INT], rffi.INT,
-    threadsafe=ts_reflect,
+    releasegil=ts_reflect,
     compilation_info=backend.eci)
 def c_is_staticdata(space, cppscope, datamember_index):
     return _c_is_staticdata(cppscope.handle, datamember_index)
 _c_strtoll = rffi.llexternal(
     "cppyy_strtoll",
     [rffi.CCHARP], rffi.LONGLONG,
-    threadsafe=ts_helper,
+    releasegil=ts_helper,
     compilation_info=backend.eci)
 def c_strtoll(space, svalue):
     return _c_strtoll(svalue)
 _c_strtoull = rffi.llexternal(
     "cppyy_strtoull",
     [rffi.CCHARP], rffi.ULONGLONG,
-    threadsafe=ts_helper,
+    releasegil=ts_helper,
     compilation_info=backend.eci)
 def c_strtoull(space, svalue):
     return _c_strtoull(svalue)
 c_free = rffi.llexternal(
     "cppyy_free",
     [rffi.VOIDP], lltype.Void,
-    threadsafe=ts_memory,
+    releasegil=ts_memory,
     compilation_info=backend.eci)
 
 def charp2str_free(space, charp):
 _c_charp2stdstring = rffi.llexternal(
     "cppyy_charp2stdstring",
     [rffi.CCHARP], C_OBJECT,
-    threadsafe=ts_helper,
+    releasegil=ts_helper,
     compilation_info=backend.eci)
 def c_charp2stdstring(space, svalue):
     charp = rffi.str2charp(svalue)
 _c_stdstring2stdstring = rffi.llexternal(
     "cppyy_stdstring2stdstring",
     [C_OBJECT], C_OBJECT,
-    threadsafe=ts_helper,
+    releasegil=ts_helper,
     compilation_info=backend.eci)
 def c_stdstring2stdstring(space, cppobject):
     return _c_stdstring2stdstring(cppobject)
 _c_assign2stdstring = rffi.llexternal(
     "cppyy_assign2stdstring",
     [C_OBJECT, rffi.CCHARP], lltype.Void,
-    threadsafe=ts_helper,
+    releasegil=ts_helper,
     compilation_info=backend.eci)
 def c_assign2stdstring(space, cppobject, svalue):
     charp = rffi.str2charp(svalue)
 _c_free_stdstring = rffi.llexternal(
     "cppyy_free_stdstring",
     [C_OBJECT], lltype.Void,
-    threadsafe=ts_helper,
+    releasegil=ts_helper,
     compilation_info=backend.eci)
 def c_free_stdstring(space, cppobject):
     _c_free_stdstring(cppobject)

File pypy/module/cppyy/capi/cint_capi.py

View file
  • Ignore whitespace
 _c_load_dictionary = rffi.llexternal(
     "cppyy_load_dictionary",
     [rffi.CCHARP], rdynload.DLLHANDLE,
-    threadsafe=False,
+    releasegil=False,
     compilation_info=eci)
 
 def c_load_dictionary(name):
 _ttree_Branch = rffi.llexternal(
     "cppyy_ttree_Branch",
     [rffi.VOIDP, rffi.CCHARP, rffi.CCHARP, rffi.VOIDP, rffi.INT, rffi.INT], rffi.LONG,
-    threadsafe=False,
+    releasegil=False,
     compilation_info=eci)
 
 @unwrap_spec(args_w='args_w')
 c_ttree_GetEntry = rffi.llexternal(
     "cppyy_ttree_GetEntry",
     [rffi.VOIDP, rffi.LONGLONG], rffi.LONGLONG,
-    threadsafe=False,
+    releasegil=False,
     compilation_info=eci)
 
 @unwrap_spec(args_w='args_w')

File pypy/module/cpyext/pystate.py

View file
  • Ignore whitespace
     it is necessary to serialize calls to this function."""
     if not space.config.translation.thread:
         raise NoThreads
-    rthread.gc_thread_prepare()
     # PyThreadState_Get will allocate a new execution context,
     # we need to protect gc and other globals with the GIL.
     rffi.aroundstate.after()

File pypy/module/crypt/interp_crypt.py

View file
  • Ignore whitespace
 else:
     eci = ExternalCompilationInfo(libraries=['crypt'])
 c_crypt = rffi.llexternal('crypt', [rffi.CCHARP, rffi.CCHARP], rffi.CCHARP,
-                          compilation_info=eci, threadsafe=False)
+                          compilation_info=eci, releasegil=False)
 
 @unwrap_spec(word=str, salt=str)
 def crypt(space, word, salt):

File pypy/module/micronumpy/arrayimpl/concrete.py

View file
  • Ignore whitespace
         self.storage = storage
 
     def create_iter(self, shape=None, backward_broadcast=False):
-        if shape is None or shape == self.get_shape():
+        if shape is None or \
+           support.product(shape) <= support.product(self.get_shape()):
             return iter.ConcreteArrayIterator(self)
         r = calculate_broadcast_strides(self.get_strides(),
                                         self.get_backstrides(),
         loop.fill(self, box.convert_to(self.dtype))
 
     def create_iter(self, shape=None, backward_broadcast=False):
-        if shape is not None and shape != self.get_shape():
+        if shape is not None and shape != self.get_shape() and \
+           support.product(shape) > support.product(self.get_shape()):
             r = calculate_broadcast_strides(self.get_strides(),
                                             self.get_backstrides(),
                                             self.get_shape(), shape,

File pypy/module/micronumpy/interp_numarray.py

View file
  • Ignore whitespace
         w_res = W_NDimArray.from_shape(space, res_shape, self.get_dtype(), w_instance=self)
         return loop.getitem_filter(w_res, self, arr)
 
-    def setitem_filter(self, space, idx, value):
-        from pypy.module.micronumpy.interp_boxes import Box
-        val = value
+    def setitem_filter(self, space, idx, val):
         if len(idx.get_shape()) > 1 and idx.get_shape() != self.get_shape():
             raise OperationError(space.w_ValueError,
                                  space.wrap("boolean index array should have 1 dimension"))
         if idx.get_size() > self.get_size():
             raise OperationError(space.w_ValueError,
                                  space.wrap("index out of range for array"))
-        idx_iter = idx.create_iter(self.get_shape())
-        size = loop.count_all_true_iter(idx_iter, self.get_shape(), idx.get_dtype())
-        if len(val.get_shape()) > 0 and val.get_shape()[0] > 1 and size > val.get_shape()[0]:
+        idx_iter = idx.create_iter()
+        size = loop.count_all_true_iter(idx_iter, idx.get_shape(), idx.get_dtype())
+        if size > val.get_size() and val.get_size() > 1:
             raise OperationError(space.w_ValueError, space.wrap("NumPy boolean array indexing assignment "
                                                                 "cannot assign %d input values to "
-                                                                "the %d output values where the mask is true" % (val.get_shape()[0],size)))
-        if val.get_shape() == [1]:
-            box = val.descr_getitem(space, space.wrap(0))
-            assert isinstance(box, Box)
-            val = W_NDimArray(scalar.Scalar(val.get_dtype(), box))
-        elif val.get_shape() == [0]:
+                                                                "the %d output values where the mask is true" % (val.get_size(), size)))
+        if val.get_shape() == [0]:
             val.implementation.dtype = self.implementation.dtype
-        loop.setitem_filter(self, idx, val)
+        loop.setitem_filter(self, idx, val, size)
 
     def _prepare_array_index(self, space, w_index):
         if isinstance(w_index, W_NDimArray):

File pypy/module/micronumpy/loop.py

View file
  • Ignore whitespace
                                                 'index_dtype'],
                                       reds = 'auto')
 
-def setitem_filter(arr, index, value):
+def setitem_filter(arr, index, value, size):
     arr_iter = arr.create_iter()
-    index_iter = index.create_iter(arr.get_shape())
-    value_iter = value.create_iter()
     shapelen = len(arr.get_shape())
+    if shapelen > 1 and len(index.get_shape()) < 2:
+        index_iter = index.create_iter(arr.get_shape(), backward_broadcast=True)
+    else:
+        index_iter = index.create_iter()
+    value_iter = value.create_iter([size])
     index_dtype = index.get_dtype()
     arr_dtype = arr.get_dtype()
     while not index_iter.done():

File pypy/module/micronumpy/test/test_dtypes.py

View file
  • Ignore whitespace
 
     def test_unicode_boxes(self):
         from numpypy import unicode_
-        assert isinstance(unicode_(3), unicode)
+        try:
+            u = unicode_(3)
+        except NotImplementedError, e:
+            if e.message.find('not supported yet') >= 0:
+                skip('unicode box not implemented')
+        else:
+            assert isinstance(u, unicode)
 
     def test_character_dtype(self):
         from numpypy import array, character

File pypy/module/micronumpy/test/test_numarray.py

View file
  • Ignore whitespace
     def test_array_indexing_bool_specialcases(self):
         from numpypy import arange, array
         a = arange(6)
-        try:
-            a[a < 3] = [1, 2]
-            assert False, "Should not work"
-        except ValueError:
-            pass
+        exc = raises(ValueError,'a[a < 3] = [1, 2]')
+        assert exc.value[0].find('cannot assign') >= 0
+        b = arange(4).reshape(2, 2) + 10
+        a[a < 4] = b
+        assert (a == [10, 11, 12, 13, 4, 5]).all()
+        b += 10
+        c = arange(8).reshape(2, 2, 2)
+        a[a > 9] = c[:, :, 1]
+        assert (c[:, :, 1] == [[1, 3], [5, 7]]).all()
+        assert (a == [1, 3, 5, 7, 4, 5]).all()
         a = arange(6)
         a[a > 3] = array([15])
         assert (a == [0, 1, 2, 3, 15, 15]).all()

File pypy/module/operator/__init__.py

View file
  • Ignore whitespace
         '__concat__' : 'concat',
         '__contains__' : 'contains',
         'sequenceIncludes' : 'contains',
+        '__index__' : 'index',
         '__delitem__' : 'delitem',
         '__div__' : 'div',
         '__eq__' : 'eq',

File pypy/module/operator/test/test_operator.py

View file
  • Ignore whitespace
         assert methodcaller("method", 4)(x) == (4, 3)
         assert methodcaller("method", 4, 5)(x) == (4, 5)
         assert methodcaller("method", 4, arg2=42)(x) == (4, 42)
+
+    def test_index(self):
+        import operator
+        assert operator.index(42) == 42
+        assert operator.__index__(42) == 42
+        raises(TypeError, operator.index, "abc")

File pypy/module/pyexpat/interp_pyexpat.py

View file
  • Ignore whitespace
 XML_ParserCreateNS = expat_external(
     'XML_ParserCreateNS', [rffi.CCHARP, rffi.CHAR], XML_Parser)
 XML_ParserFree = expat_external(
-    'XML_ParserFree', [XML_Parser], lltype.Void, threadsafe=False)
+    'XML_ParserFree', [XML_Parser], lltype.Void, releasegil=False)
 XML_SetUserData = expat_external(
     'XML_SetUserData', [XML_Parser, rffi.VOIDP], lltype.Void)
 def XML_GetUserData(parser):

File pypy/module/pypyjit/policy.py

View file
  • Ignore whitespace
                        'posix', '_socket', '_sre', '_lsprof', '_weakref',
                        '__pypy__', 'cStringIO', '_collections', 'struct',
                        'mmap', 'marshal', '_codecs', 'rctime', 'cppyy',
-                       '_cffi_backend', 'pyexpat', '_continuation', '_io']:
+                       '_cffi_backend', 'pyexpat', '_continuation', '_io',
+                       'thread']:
             if modname == 'pypyjit' and 'interp_resop' in rest:
                 return False
             return True

File pypy/module/pypyjit/test/test_policy.py

View file
  • Ignore whitespace
     from pypy.module._io.interp_bytesio import W_BytesIO
     assert pypypolicy.look_inside_function(W_BytesIO.seek_w.im_func)
 
+def test_thread():
+    from pypy.module.thread.os_lock import Lock
+    assert pypypolicy.look_inside_function(Lock.descr_lock_acquire.im_func)
+
 def test_pypy_module():
     from pypy.module._collections.interp_deque import W_Deque
     from pypy.module._random.interp_random import W_Random

File pypy/module/pypyjit/test_pypy_c/test_thread.py

View file
  • Ignore whitespace
+import py
 from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
 
 
             i58 = arraylen_gc(p43, descr=...)
             jump(..., descr=...)
         """)
+
+    def test_lock_acquire_release(self):
+        py.test.skip("test too precise, please fix me")
+        def main(n):
+            import threading
+            lock = threading.Lock()
+            while n > 0:
+                with lock:
+                    n -= 1
+        log = self.run(main, [500])
+        assert log.result == main(500)
+        loop, = log.loops_by_filename(self.filepath)
+        assert loop.match("""
+        i58 = int_gt(i43, 0)
+        guard_true(i58, descr=<Guard0x10483adb8>)
+        p59 = getfield_gc(p15, descr=<FieldP pypy.module.thread.os_lock.Lock.inst_lock 8>)
+        i60 = getfield_gc(p59, descr=<FieldU rpython.rlib.rthread.Lock.inst__lock 8>)
+        p61 = force_token()
+        setfield_gc(p0, p61, descr=<FieldP pypy.interpreter.pyframe.PyFrame.vable_token 24>)
+        i62 = call_release_gil(4312440032, i60, 1, descr=<Calli 4 ii EF=6>)
+        guard_not_forced(descr=<Guard0x103f3cca0>)
+        guard_no_exception(descr=<Guard0x10483ad40>)
+        i63 = int_is_true(i62)
+        guard_true(i63, descr=<Guard0x10483acc8>)
+        i64 = int_sub(i43, 1)
+        guard_not_invalidated(descr=<Guard0x10483ac50>)
+        p66 = getfield_gc(p15, descr=<FieldP pypy.module.thread.os_lock.Lock.inst_lock 8>)
+        i67 = getfield_gc(p66, descr=<FieldU rpython.rlib.rthread.Lock.inst__lock 8>)
+        p68 = force_token()
+        setfield_gc(p0, p68, descr=<FieldP pypy.interpreter.pyframe.PyFrame.vable_token 24>)
+        i69 = call_release_gil(4312440032, i67, 0, descr=<Calli 4 ii EF=6>)
+        guard_not_forced(descr=<Guard0x103f3cc20>)
+        guard_no_exception(descr=<Guard0x10483aae8>)
+        i70 = int_is_true(i69)
+        guard_false(i70, descr=<Guard0x10483aa70>)
+        i71 = getfield_gc(p66, descr=<FieldU rpython.rlib.rthread.Lock.inst__lock 8>)
+        p72 = force_token()
+        setfield_gc(p0, p72, descr=<FieldP pypy.interpreter.pyframe.PyFrame.vable_token 24>)
+        call_release_gil(4312441056, i71, descr=<Callv 0 i EF=6>)
+        guard_not_forced(descr=<Guard0x103f3cba0>)
+        guard_no_exception(descr=<Guard0x10483a9f8>)
+        guard_not_invalidated(descr=<Guard0x10483a980>)
+        --TICK--
+        jump(..., descr=TargetToken(4361239720))
+        """)

File pypy/module/rctime/interp_time.py

View file
  • Ignore whitespace
     return rffi.llexternal(name, args, result,
                            compilation_info=eci,
                            calling_conv=calling_conv,
-                           threadsafe=False)
+                           releasegil=False)
 
 if _POSIX:
     cConfig.timeval.__name__ = "_timeval"

File pypy/module/test_lib_pypy/cffi_tests/backend_tests.py

View file
  • Ignore whitespace
         typerepr = self.TypeRepr
         ffi = FFI(backend=self.Backend())
         ffi.cdef("struct foo { short a, b, c; };")
+        p = ffi.cast("short unsigned int", 0)
+        assert repr(p) == "<cdata 'unsigned short' 0>"
+        assert repr(ffi.typeof(p)) == typerepr % "unsigned short"
         p = ffi.cast("unsigned short int", 0)
         assert repr(p) == "<cdata 'unsigned short' 0>"
         assert repr(ffi.typeof(p)) == typerepr % "unsigned short"
         for c_type, expected_size in [
             ('char', 1),
             ('unsigned int', 4),
-            ('char *', SIZE_OF_LONG),
+            ('char *', SIZE_OF_PTR),
             ('int[5]', 20),
             ('struct foo', 12),
             ('union foo', 4),
             ]:
             size = ffi.sizeof(c_type)
-            assert size == expected_size
+            assert size == expected_size, (size, expected_size, ctype)
 
     def test_sizeof_cdata(self):
         ffi = FFI(backend=self.Backend())

File pypy/module/test_lib_pypy/cffi_tests/callback_in_thread.py

View file
  • Ignore whitespace
     seen = []
     @ffi.callback('int(*)(int,int)')
     def mycallback(x, y):
+        time.sleep(0.022)
         seen.append((x, y))
         return 0
     lib.threaded_ballback_test(mycallback)

File pypy/module/test_lib_pypy/cffi_tests/test_function.py

View file
  • Ignore whitespace
         sin100 = my_decorator(m.sin)
         x = sin100(1.23)
         assert x == math.sin(1.23) + 100
+
+    def test_free_callback_cycle(self):
+        if self.Backend is CTypesBackend:
+            py.test.skip("seems to fail with the ctypes backend on windows")
+        import weakref
+        def make_callback(data):
+            container = [data]
+            callback = ffi.callback('int()', lambda: len(container))
+            container.append(callback)
+            # Ref cycle: callback -> lambda (closure) -> container -> callback
+            return callback
+
+        class Data(object):
+            pass
+        ffi = FFI(backend=self.Backend())
+        data = Data()
+        callback = make_callback(data)
+        wr = weakref.ref(data)
+        del callback, data
+        for i in range(3):
+            if wr() is not None:
+                import gc; gc.collect()
+        assert wr() is None    # 'data' does not leak

File pypy/module/test_lib_pypy/cffi_tests/test_version.py

View file
  • Ignore whitespace
 
 BACKEND_VERSIONS = {
     '0.4.2': '0.4',     # did not change
+    '0.7.1': '0.7',     # did not change
+    '0.7.2': '0.7',     # did not change
     }
 
 def test_version():
     content = open(p).read()
     #
     v = cffi.__version__
-    assert ("version = '%s'\n" % v) in content
+    assert ("version = '%s'\n" % BACKEND_VERSIONS.get(v, v)) in content
     assert ("release = '%s'\n" % v) in content
 
 def test_doc_version_file():
     v = cffi.__version__
     p = os.path.join(parent, 'c', 'test_c.py')
     content = open(p).read()
-    assert ('assert __version__ == "%s"' % v) in content
+    assert (('assert __version__ == "%s"' % BACKEND_VERSIONS.get(v, v))
+            in content)

File pypy/module/test_lib_pypy/test_curses.py

View file
  • Ignore whitespace