Author: mattip <[email protected]> Branch: cpyext-ext Changeset: r81444:3baca7226714 Date: 2015-12-24 17:26 +0200 http://bitbucket.org/pypy/pypy/changeset/3baca7226714/
Log: merge default into branch diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO --- a/lib_pypy/cffi.egg-info/PKG-INFO +++ b/lib_pypy/cffi.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: cffi -Version: 1.4.1 +Version: 1.4.2 Summary: Foreign Function Interface for Python calling C code. Home-page: http://cffi.readthedocs.org Author: Armin Rigo, Maciej Fijalkowski diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py --- a/lib_pypy/cffi/__init__.py +++ b/lib_pypy/cffi/__init__.py @@ -4,8 +4,8 @@ from .api import FFI, CDefError, FFIError from .ffiplatform import VerificationError, VerificationMissing -__version__ = "1.4.1" -__version_info__ = (1, 4, 1) +__version__ = "1.4.2" +__version_info__ = (1, 4, 2) # The verifier module file names are based on the CRC32 of a string that # contains the following version number. It may be older than __version__ diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py --- a/pypy/module/cpyext/slotdefs.py +++ b/pypy/module/cpyext/slotdefs.py @@ -4,7 +4,8 @@ from rpython.rtyper.lltypesystem import rffi, lltype from pypy.module.cpyext.api import ( - cpython_api, generic_cpy_call, PyObject, Py_ssize_t, Py_TPFLAGS_CHECKTYPES) + cpython_api, generic_cpy_call, PyObject, Py_ssize_t, Py_TPFLAGS_CHECKTYPES, + CANNOT_FAIL) from pypy.module.cpyext.typeobjectdefs import ( unaryfunc, wrapperfunc, ternaryfunc, PyTypeObjectPtr, binaryfunc, getattrfunc, getattrofunc, setattrofunc, lenfunc, ssizeargfunc, inquiry, @@ -386,7 +387,7 @@ return @cpython_api([PyObject, PyObject], PyObject, - error=lltype.nullptr(rffi.VOIDP.TO), external=True) + error=CANNOT_FAIL, external=True) @func_renamer("cpyext_tp_getattro_%s" % (typedef.name,)) def slot_tp_getattro(space, w_self, w_name): return space.call_function(getattr_fn, w_self, w_name) diff --git a/rpython/rlib/rurandom.py b/rpython/rlib/rurandom.py --- a/rpython/rlib/rurandom.py +++ b/rpython/rlib/rurandom.py @@ -86,27 +86,29 @@ else: # Posix implementation def init_urandom(): """NOT_RPYTHON - Return an array of one int, initialized to 0. - It is filled automatically the first time urandom() is called. """ - return lltype.malloc(rffi.CArray(lltype.Signed), 1, - immortal=True, zero=True) + return None def urandom(context, n): "Read n bytes from /dev/urandom." result = '' if n == 0: return result - if not context[0]: - context[0] = os.open("/dev/urandom", os.O_RDONLY, 0777) - while n > 0: - try: - data = os.read(context[0], n) - except OSError, e: - if e.errno != errno.EINTR: - raise - data = '' - result += data - n -= len(data) + # XXX should somehow cache the file descriptor. It's a mess. + # CPython has a 99% solution and hopes for the remaining 1% + # not to occur. For now, we just don't cache the file + # descriptor (any more... 6810f401d08e). + fd = os.open("/dev/urandom", os.O_RDONLY, 0777) + try: + while n > 0: + try: + data = os.read(fd, n) + except OSError, e: + if e.errno != errno.EINTR: + raise + data = '' + result += data + n -= len(data) + finally: + os.close(fd) return result - _______________________________________________ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
