[pypy-commit] pypy py3k: revert last commit, remove already defined function in RPython (is provided in C)

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3k
Changeset: r86519:2a28c3d0f49d
Date: 2016-08-25 07:34 +0200
http://bitbucket.org/pypy/pypy/changeset/2a28c3d0f49d/

Log:revert last commit, remove already defined function in RPython (is
provided in C)

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -516,7 +516,7 @@
 'PyObject_CallMethod', 'PyObject_CallFunctionObjArgs', 
'PyObject_CallMethodObjArgs',
 '_PyObject_CallFunction_SizeT', '_PyObject_CallMethod_SizeT',
 
-'PyBuffer_Release',
+'PyObject_GetBuffer', 'PyBuffer_Release',
 
 'PyCObject_FromVoidPtr', 'PyCObject_FromVoidPtrAndDesc', 
'PyCObject_AsVoidPtr',
 'PyCObject_GetDesc', 'PyCObject_Import', 'PyCObject_SetVoidPtr',
diff --git a/pypy/module/cpyext/buffer.py b/pypy/module/cpyext/buffer.py
--- a/pypy/module/cpyext/buffer.py
+++ b/pypy/module/cpyext/buffer.py
@@ -5,33 +5,8 @@
 cpython_api, CANNOT_FAIL, Py_buffer)
 from pypy.module.cpyext.pyobject import PyObject, Py_DecRef
 
-@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
-def PyObject_CheckBuffer(space, w_obj):
-"""Return 1 if obj supports the buffer interface otherwise 0."""
-return 0  # the bf_getbuffer field is never filled by cpyext
-
-@cpython_api([PyObject, lltype.Ptr(Py_buffer), rffi.INT_real],
- rffi.INT_real, error=-1)
-def PyObject_GetBuffer(space, w_obj, view, flags):
-"""Export obj into a Py_buffer, view.  These arguments must
-never be NULL.  The flags argument is a bit field indicating what
-kind of buffer the caller is prepared to deal with and therefore what
-kind of buffer the exporter is allowed to return.  The buffer interface
-allows for complicated memory sharing possibilities, but some caller may
-not be able to handle all the complexity but may want to see if the
-exporter will let them take a simpler view to its memory.
-
-Some exporters may not be able to share memory in every possible way and
-may need to raise errors to signal to some consumers that something is
-just not possible. These errors should be a BufferError unless
-there is another error that is actually causing the problem. The
-exporter can use flags information to simplify how much of the
-Py_buffer structure is filled in with non-default values and/or
-raise an error if the object can't support a simpler view of its memory.
-
-0 is returned on success and -1 on error."""
-raise oefmt(space.w_TypeError,
-"PyPy does not yet implement the new buffer interface")
+# PyObject_GetBuffer has been removed, it is defined in abstract.c
+# PyObject_CheckBuffer is also already defined
 
 @cpython_api([lltype.Ptr(Py_buffer), lltype.Char], rffi.INT_real, 
error=CANNOT_FAIL)
 def PyBuffer_IsContiguous(space, view, fortran):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-5.x: update version to 5.4.0

2016-08-24 Thread mattip
Author: Matti Picus 
Branch: release-5.x
Changeset: r86517:a1c30344b9b9
Date: 2016-08-25 09:10 +1000
http://bitbucket.org/pypy/pypy/changeset/a1c30344b9b9/

Log:update version to 5.4.0

diff --git a/pypy/module/cpyext/include/patchlevel.h 
b/pypy/module/cpyext/include/patchlevel.h
--- a/pypy/module/cpyext/include/patchlevel.h
+++ b/pypy/module/cpyext/include/patchlevel.h
@@ -29,8 +29,8 @@
 #define PY_VERSION "2.7.10"
 
 /* PyPy version as a string */
-#define PYPY_VERSION "5.4.1-alpha0"
-#define PYPY_VERSION_NUM  0x05040100
+#define PYPY_VERSION "5.4.0"
+#define PYPY_VERSION_NUM  0x0504
 
 /* Defined to mean a PyPy where cpyext holds more regular references
to PyObjects, e.g. staying alive as long as the internal PyPy object
diff --git a/pypy/module/sys/version.py b/pypy/module/sys/version.py
--- a/pypy/module/sys/version.py
+++ b/pypy/module/sys/version.py
@@ -10,7 +10,7 @@
 #XXX # sync CPYTHON_VERSION with patchlevel.h, package.py
 CPYTHON_API_VERSION= 1013   #XXX # sync with include/modsupport.h
 
-PYPY_VERSION   = (5, 4, 1, "alpha", 0)#XXX # sync patchlevel.h
+PYPY_VERSION   = (5, 4, 0, "final", 0)#XXX # sync patchlevel.h
 
 
 import pypy
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy asmmemmgr-for-code-only: Fix a load of W^X violations touched in the x86 backend tests.

2016-08-24 Thread vext01
Author: Edd Barrett 
Branch: asmmemmgr-for-code-only
Changeset: r86511:c7822af728c9
Date: 2016-08-24 23:48 +0100
http://bitbucket.org/pypy/pypy/changeset/c7822af728c9/

Log:Fix a load of W^X violations touched in the x86 backend tests.

diff --git a/rpython/jit/backend/llsupport/asmmemmgr.py 
b/rpython/jit/backend/llsupport/asmmemmgr.py
--- a/rpython/jit/backend/llsupport/asmmemmgr.py
+++ b/rpython/jit/backend/llsupport/asmmemmgr.py
@@ -230,8 +230,11 @@
 targetindex = self._baserelpos
 while targetindex >= 0:
 dst = rffi.cast(rffi.CCHARP, addr + targetindex)
+# XXX see if we can move the page fiddling out the loop
+rmmap.set_pages_writable(dst, blocksize)
 for j in range(blocksize):
 dst[j] = block.data[j]
+rmmap.set_pages_executable(dst, blocksize)
 block = block.prev
 blocksize = self.SUBBLOCK_SIZE
 targetindex -= self.SUBBLOCK_SIZE
diff --git a/rpython/jit/backend/llsupport/gcreftracer.py 
b/rpython/jit/backend/llsupport/gcreftracer.py
--- a/rpython/jit/backend/llsupport/gcreftracer.py
+++ b/rpython/jit/backend/llsupport/gcreftracer.py
@@ -2,6 +2,7 @@
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.jit.backend.llsupport.symbolic import WORD
+from rpython.rlib.rmmap import set_pages_executable, set_pages_writable
 
 
 GCREFTRACER = lltype.GcStruct(
@@ -43,7 +44,10 @@
 def make_boehm_tracer(array_base_addr, gcrefs):
 # copy the addresses, but return 'gcrefs' as the object that must be
 # kept alive
-for i in range(len(gcrefs)):
+n_gcrefs = len(gcrefs)
+set_pages_writable(array_base_addr, n_gcrefs * WORD)
+for i in range(n_gcrefs):
 p = rffi.cast(rffi.SIGNEDP, array_base_addr + i * WORD)
 p[0] = rffi.cast(lltype.Signed, gcrefs[i])
+set_pages_executable(array_base_addr, n_gcrefs * WORD)
 return gcrefs
diff --git a/rpython/jit/backend/x86/codebuf.py 
b/rpython/jit/backend/x86/codebuf.py
--- a/rpython/jit/backend/x86/codebuf.py
+++ b/rpython/jit/backend/x86/codebuf.py
@@ -7,6 +7,7 @@
 from rpython.jit.backend.x86.regloc import LocationCodeBuilder
 from rpython.jit.backend.x86.arch import IS_X86_32, IS_X86_64, WORD
 from rpython.jit.backend.x86 import valgrind
+from rpython.rlib.rmmap import  set_pages_writable, set_pages_executable
 
 # XXX: Seems nasty to change the superclass of MachineCodeBlockWrapper
 # like this
@@ -51,5 +52,6 @@
 p = addr + reloc
 adr = rffi.cast(rffi.INTP, p - 4)
 adr[0] = rffi.cast(rffi.INT, intmask(adr[0]) - p)
+
 valgrind.discard_translations(addr, self.get_relative_pos())
 self._dump(addr, "jit-backend-dump", backend_name)
diff --git a/rpython/jit/backend/x86/detect_feature.py 
b/rpython/jit/backend/x86/detect_feature.py
--- a/rpython/jit/backend/x86/detect_feature.py
+++ b/rpython/jit/backend/x86/detect_feature.py
@@ -1,17 +1,23 @@
 import sys
 import struct
 from rpython.rtyper.lltypesystem import lltype, rffi
-from rpython.rlib.rmmap import alloc, free
+from rpython.rlib.rmmap import (alloc, free, set_pages_writable,
+set_pages_executable)
+
+CPUINFO_ALLOC_SZ = 4096
+
 
 def cpu_info(instr):
-data = alloc(4096)
+data = alloc(CPUINFO_ALLOC_SZ)
 pos = 0
+set_pages_writable(data, CPUINFO_ALLOC_SZ)
 for c in instr:
 data[pos] = c
 pos += 1
+set_pages_executable(data, CPUINFO_ALLOC_SZ)
 fnptr = rffi.cast(lltype.Ptr(lltype.FuncType([], lltype.Signed)), data)
 code = fnptr()
-free(data, 4096)
+free(data, CPUINFO_ALLOC_SZ)
 return code
 
 def detect_sse2():
diff --git a/rpython/jit/backend/x86/test/test_regloc.py 
b/rpython/jit/backend/x86/test/test_regloc.py
--- a/rpython/jit/backend/x86/test/test_regloc.py
+++ b/rpython/jit/backend/x86/test/test_regloc.py
@@ -7,6 +7,7 @@
 from rpython.jit.backend.x86 import codebuf
 from rpython.jit.backend.x86.callbuilder import follow_jump
 from rpython.rlib.rarithmetic import intmask
+from rpython.rlib import rmmap
 import py.test
 
 class LocationCodeBuilder32(CodeBuilder32, LocationCodeBuilder):
@@ -78,7 +79,7 @@
 mc = codebuf.MachineCodeBlockWrapper()
 mc.CALL(ImmedLoc(target))
 length = mc.get_relative_pos()
-buf = lltype.malloc(rffi.CCHARP.TO, length, flavor='raw')
+buf = rmmap.alloc(length)
 rawstart = rffi.cast(lltype.Signed, buf)
 if IS_X86_32:
 assert length == 5
@@ -103,17 +104,18 @@
 "\x41\xFF\xD3") # CALL *%r11
 mc.copy_to_raw_memory(rawstart)
 assert ''.join([buf[i] for i in range(length)]) == expected
-lltype.free(buf, flavor='raw')
+rmmap.free(buf, length)
 
 class Fake32CodeBlockWrapper(codebuf.MachineCodeBlockWrapper):
 def check_stack_size_at_ret(self):
  

[pypy-commit] pypy default: tweak docs

2016-08-24 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r86518:3fefa85e84f5
Date: 2016-08-25 09:25 +1000
http://bitbucket.org/pypy/pypy/changeset/3fefa85e84f5/

Log:tweak docs

diff --git a/pypy/doc/conf.py b/pypy/doc/conf.py
--- a/pypy/doc/conf.py
+++ b/pypy/doc/conf.py
@@ -58,16 +58,16 @@
 
 # General information about the project.
 project = u'PyPy'
-copyright = u'2015, The PyPy Project'
+copyright = u'2016, The PyPy Project'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
 # The short X.Y version.
-version = '4.0'
+version = '5.4'
 # The full version, including alpha/beta/rc tags.
-release = '4.0.0'
+release = '5.4.0'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/pypy/doc/index-of-whatsnew.rst b/pypy/doc/index-of-whatsnew.rst
--- a/pypy/doc/index-of-whatsnew.rst
+++ b/pypy/doc/index-of-whatsnew.rst
@@ -7,6 +7,7 @@
 .. toctree::
 
whatsnew-head.rst
+   whatsnew-pypy2-5.4.0.rst
whatsnew-pypy2-5.3.1.rst
whatsnew-pypy2-5.3.0.rst
whatsnew-5.1.0.rst
diff --git a/pypy/doc/project-ideas.rst b/pypy/doc/project-ideas.rst
--- a/pypy/doc/project-ideas.rst
+++ b/pypy/doc/project-ideas.rst
@@ -57,7 +57,7 @@
 --
 
 Our cpyext C-API compatiblity layer can now run upstream NumPy unmodified.
-Release PyPy2.7-v5.3 still fails about 200 of the ~6000 test in the NumPy
+Release PyPy2.7-v5.4 still fails about 60 of the ~6000 test in the NumPy
 test suite. We could use help analyzing the failures and fixing them either
 as patches to upstream NumPy, or as fixes to PyPy.
 
diff --git a/pypy/doc/release-pypy2.7-v5.4.0.rst 
b/pypy/doc/release-pypy2.7-v5.4.0.rst
--- a/pypy/doc/release-pypy2.7-v5.4.0.rst
+++ b/pypy/doc/release-pypy2.7-v5.4.0.rst
@@ -135,7 +135,7 @@
 RPython functions, eventually exhausting the stack, while at
 app-level the traceback is very short
 
-.. _resolved: http://doc.pypy.org/en/latest/whatsnew-5.3.0.html
+.. _resolved: http://doc.pypy.org/en/latest/whatsnew-5.4.0.html
 
 Please update, and continue to help us make PyPy better.
 
diff --git a/pypy/doc/whatsnew-pypy2-5.4.0.rst 
b/pypy/doc/whatsnew-pypy2-5.4.0.rst
--- a/pypy/doc/whatsnew-pypy2-5.4.0.rst
+++ b/pypy/doc/whatsnew-pypy2-5.4.0.rst
@@ -1,6 +1,6 @@
-==
-What's new in PyPy2.7 5.3+
-==
+=
+What's new in PyPy2.7 5.4
+=
 
 .. this is a revision shortly after release-pypy2.7-v5.3
 .. startrev: 873218a739f1
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy release-5.x: merge default into release branch

2016-08-24 Thread mattip
Author: Matti Picus 
Branch: release-5.x
Changeset: r86516:b637e157f241
Date: 2016-08-25 09:03 +1000
http://bitbucket.org/pypy/pypy/changeset/b637e157f241/

Log:merge default into release branch

diff too long, truncating to 2000 out of 25848 lines

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -26,3 +26,4 @@
 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
 c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3
+7e8df3df96417c16c2d55b41352ec82c9c69c978 release-pypy2.7-v5.3.1
diff --git a/dotviewer/graphparse.py b/dotviewer/graphparse.py
--- a/dotviewer/graphparse.py
+++ b/dotviewer/graphparse.py
@@ -85,10 +85,11 @@
 pass
 
 def splitline(line, re_word = re.compile(r'[^\s"]\S*|["]["]|["].*?[^\\]["]')):
+import ast
 result = []
 for word in re_word.findall(line):
 if word.startswith('"'):
-word = eval(word)
+word = ast.literal_eval(word)
 result.append(word)
 return result
 
diff --git a/include/PyPy.h b/include/PyPy.h
--- a/include/PyPy.h
+++ b/include/PyPy.h
@@ -2,7 +2,11 @@
 #define _PYPY_H_
 
 /* This header is meant to be included in programs that use PyPy as an
-   embedded library. */
+   embedded library.
+
+   NOTE: this is deprecated.  Instead, use cffi's embedding support:
+   http://cffi.readthedocs.org/en/latest/embedding.html
+*/
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/lib-python/2.7/test/test_hash.py b/lib-python/2.7/test/test_hash.py
--- a/lib-python/2.7/test/test_hash.py
+++ b/lib-python/2.7/test/test_hash.py
@@ -174,7 +174,7 @@
 
 class StringlikeHashRandomizationTests(HashRandomizationTests):
 if check_impl_detail(pypy=True):
-EMPTY_STRING_HASH = -1
+EMPTY_STRING_HASH = -2
 else:
 EMPTY_STRING_HASH = 0
 
diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -167,7 +167,7 @@
 else:
 return self.value
 
-def __buffer__(self):
+def __buffer__(self, flags):
 return buffer(self._buffer)
 
 def _get_b_base(self):
@@ -199,10 +199,13 @@
 return tp._alignmentofinstances()
 
 @builtinify
-def byref(cdata):
+def byref(cdata, offset=0):
 # "pointer" is imported at the end of this module to avoid circular
 # imports
-return pointer(cdata)
+ptr = pointer(cdata)
+if offset != 0:
+ptr._buffer[0] += offset
+return ptr
 
 def cdata_from_address(self, address):
 # fix the address: turn it into as unsigned, in case it's a negative number
diff --git a/lib_pypy/_pypy_winbase_build.py b/lib_pypy/_pypy_winbase_build.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_pypy_winbase_build.py
@@ -0,0 +1,91 @@
+# Note: uses the CFFI out-of-line ABI mode.  We can't use the API
+# mode because ffi.compile() needs to run the compiler, which
+# needs 'subprocess', which needs 'msvcrt' and '_subprocess',
+# which depend on '_pypy_winbase_cffi' already.
+#
+# Note that if you need to regenerate _pypy_winbase_cffi and
+# can't use a preexisting PyPy to do that, then running this
+# file should work as long as 'subprocess' is not imported
+# by cffi.  I had to hack in 'cffi._pycparser' to move an
+#'import subprocess' to the inside of a function.  (Also,
+# CPython+CFFI should work as well.)
+#
+# This module supports both msvcrt.py and _subprocess.py.
+
+from cffi import FFI
+
+ffi = FFI()
+
+ffi.set_source("_pypy_winbase_cffi", None)
+
+# -- MSVCRT --
+
+ffi.cdef("""
+typedef unsigned short wint_t;
+
+int _open_osfhandle(intptr_t osfhandle, int flags);
+intptr_t _get_osfhandle(int fd);
+int _setmode(int fd, int mode);
+int _locking(int fd, int mode, long nbytes);
+
+int _kbhit(void);
+int _getch(void);
+wint_t _getwch(void);
+int _getche(void);
+wint_t _getwche(void);
+int _putch(int);
+wint_t _putwch(wchar_t);
+int _ungetch(int);
+wint_t _ungetwch(wint_t);
+""")
+
+# -- SUBPROCESS --
+
+ffi.cdef("""
+typedef struct {
+DWORD  cb;
+char * lpReserved;
+char * lpDesktop;
+char * lpTitle;
+DWORD  dwX;
+DWORD  dwY;
+DWORD  dwXSize;
+DWORD  dwYSize;
+DWORD  dwXCountChars;
+DWORD  dwYCountChars;
+DWORD  dwFillAttribute;
+DWORD  dwFlags;
+WORD   wShowWindow;
+WORD   cbReserved2;
+LPBYTE lpReserved2;
+HANDLE hStdInput;
+HANDLE hStdOutput;
+HANDLE hStdError;
+} STARTUPINFO, *LPSTARTUPINFO;
+
+typedef struct {
+HANDLE hProcess;
+HANDLE hThread;
+DWORD  dwProcessId;
+DWORD  dwThreadId;
+} PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
+
+DWORD WINAPI GetVersion(void);
+BOOL WINAPI CreatePipe(PHANDLE, PHANDLE, void *, DWORD);
+BOOL WINAPI CloseHandle(HANDLE);
+HANDLE WINAPI GetCurrentProcess(void);
+BOOL WINAPI DuplicateHandle(HANDLE, HANDLE, HANDLE, LPHANDLE,
+DWORD, BOOL, DWORD);
+BOOL WINAPI 

[pypy-commit] pypy default: restart whatsnew

2016-08-24 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r86515:9734e4f070e5
Date: 2016-08-25 09:00 +1000
http://bitbucket.org/pypy/pypy/changeset/9734e4f070e5/

Log:restart whatsnew

diff --git a/pypy/doc/whatnew-head.rst b/pypy/doc/whatnew-head.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/whatnew-head.rst
@@ -0,0 +1,8 @@
+==
+What's new in PyPy2.7 5.4+
+==
+
+.. this is a revision shortly after release-pypy2.7-v5.4
+.. startrev: 531050b1f410
+
+
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: update version numbers for release

2016-08-24 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r86514:531050b1f410
Date: 2016-08-25 08:59 +1000
http://bitbucket.org/pypy/pypy/changeset/531050b1f410/

Log:update version numbers for release

diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-pypy2-5.4.0.rst
rename from pypy/doc/whatsnew-head.rst
rename to pypy/doc/whatsnew-pypy2-5.4.0.rst
diff --git a/pypy/module/cpyext/include/patchlevel.h 
b/pypy/module/cpyext/include/patchlevel.h
--- a/pypy/module/cpyext/include/patchlevel.h
+++ b/pypy/module/cpyext/include/patchlevel.h
@@ -29,8 +29,8 @@
 #define PY_VERSION "2.7.10"
 
 /* PyPy version as a string */
-#define PYPY_VERSION "5.3.2-alpha0"
-#define PYPY_VERSION_NUM  0x05030200
+#define PYPY_VERSION "5.4.1-alpha0"
+#define PYPY_VERSION_NUM  0x05040100
 
 /* Defined to mean a PyPy where cpyext holds more regular references
to PyObjects, e.g. staying alive as long as the internal PyPy object
diff --git a/pypy/module/sys/version.py b/pypy/module/sys/version.py
--- a/pypy/module/sys/version.py
+++ b/pypy/module/sys/version.py
@@ -10,7 +10,7 @@
 #XXX # sync CPYTHON_VERSION with patchlevel.h, package.py
 CPYTHON_API_VERSION= 1013   #XXX # sync with include/modsupport.h
 
-PYPY_VERSION   = (5, 3, 2, "alpha", 0)#XXX # sync patchlevel.h
+PYPY_VERSION   = (5, 4, 1, "alpha", 0)#XXX # sync patchlevel.h
 
 
 import pypy
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy w-xor-x2: Allocate mmap pages with PROT_NONE and provide ability to use mprotect.

2016-08-24 Thread vext01
Author: Edd Barrett 
Branch: w-xor-x2
Changeset: r86509:027b44340648
Date: 2016-08-24 23:43 +0100
http://bitbucket.org/pypy/pypy/changeset/027b44340648/

Log:Allocate mmap pages with PROT_NONE and provide ability to use
mprotect.

diff --git a/rpython/rlib/rmmap.py b/rpython/rlib/rmmap.py
--- a/rpython/rlib/rmmap.py
+++ b/rpython/rlib/rmmap.py
@@ -57,7 +57,7 @@
 # some constants are linux only so they will be correctly exposed outside
 # depending on the OS
 constant_names = ['MAP_SHARED', 'MAP_PRIVATE', 'MAP_FIXED',
-  'PROT_READ', 'PROT_WRITE',
+  'PROT_READ', 'PROT_WRITE', 'PROT_NONE',
   'MS_SYNC']
 opt_constant_names = ['MAP_ANON', 'MAP_ANONYMOUS', 'MAP_NORESERVE',
   'PROT_EXEC',
@@ -155,6 +155,10 @@
 c_mmap, c_mmap_safe = external('mmap', [PTR, size_t, rffi.INT, rffi.INT,
rffi.INT, off_t], PTR, macro=True,
save_err_on_unsafe=rffi.RFFI_SAVE_ERRNO)
+
+_, c_mprotect_safe = external('mprotect', [PTR, size_t, rffi.INT],
+  rffi.INT, _nowrapper=True)
+
 # 'mmap' on linux32 is a macro that calls 'mmap64'
 _, c_munmap_safe = external('munmap', [PTR, size_t], rffi.INT)
 c_msync, _ = external('msync', [PTR, size_t, rffi.INT], rffi.INT,
@@ -172,6 +176,8 @@
 _get_allocation_granularity = _get_page_size = lambda: _pagesize
 
 elif _MS_WINDOWS:
+# XXX mprotect equivalent
+# XXX set_pages_executable/writable equivalent
 
 class ComplexCConfig:
 _compilation_info_ = CConfig._compilation_info_
@@ -707,12 +713,29 @@
 
 def alloc_hinted(hintp, map_size):
 flags = MAP_PRIVATE | MAP_ANONYMOUS
-prot = PROT_EXEC | PROT_READ | PROT_WRITE
+# Pages start with no permissions
+prot = PROT_NONE
 if we_are_translated():
 flags = NonConstant(flags)
 prot = NonConstant(prot)
 return c_mmap_safe(hintp, map_size, prot, flags, -1, 0)
 
+def mprotect(addr, size, prot):
+addr = rffi.cast(PTR, addr)
+size = rffi.cast(lltype.Unsigned, size)
+prot = rffi.cast(rffi.INT, prot)
+return c_mprotect_safe(addr, size, prot)
+
+def set_pages_executable(addr, size):
+rv = mprotect(addr, size, PROT_EXEC | PROT_READ)
+if rv < 0:
+debug.fatalerror_notb("set_pages_executable failed")
+
+def set_pages_writable(addr, size):
+rv = mprotect(addr, size, PROT_WRITE | PROT_READ)
+if rv < 0:
+debug.fatalerror_notb("set_pages_executable failed")
+
 def clear_large_memory_chunk_aligned(addr, map_size):
 addr = rffi.cast(PTR, addr)
 flags = MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy w-xor-x2: Don't use this branch.

2016-08-24 Thread vext01
Author: Edd Barrett 
Branch: w-xor-x2
Changeset: r86513:faca61b444b4
Date: 2016-08-25 00:05 +0100
http://bitbucket.org/pypy/pypy/changeset/faca61b444b4/

Log:Don't use this branch.

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy asmmemmgr-for-code-only: Mark a couple of tests xfail on OpenBSD (and apply half a fix).

2016-08-24 Thread vext01
Author: Edd Barrett 
Branch: asmmemmgr-for-code-only
Changeset: r86512:e50cf5d2ead3
Date: 2016-08-25 00:02 +0100
http://bitbucket.org/pypy/pypy/changeset/e50cf5d2ead3/

Log:Mark a couple of tests xfail on OpenBSD (and apply half a fix).

libdl is not used on OpenBSD for sure, but these tests still fail
when invoking dlopen() for some reason I can't figure out.

I'm not sure this is related to W^X but it may be.

diff --git a/rpython/jit/backend/test/runner_test.py 
b/rpython/jit/backend/test/runner_test.py
--- a/rpython/jit/backend/test/runner_test.py
+++ b/rpython/jit/backend/test/runner_test.py
@@ -1,4 +1,5 @@
 import py, sys, random, os, struct, operator
+import pytest
 from rpython.jit.metainterp.history import (AbstractFailDescr,
  AbstractDescr,
  BasicFailDescr,
@@ -2599,6 +2600,8 @@
 deadframe2 = self.cpu.force(frame)
 assert self.cpu.get_int_value(deadframe2, 0) == 30
 
+@pytest.mark.xfail(sys.platform.startswith("openbsd"),
+   reason="something wrong with CDLL()")
 def test_call_to_c_function(self):
 from rpython.rlib.libffi import CDLL, types, ArgChain, FUNCFLAG_CDECL
 from rpython.rtyper.lltypesystem.ll2ctypes import libc_name
@@ -2625,6 +2628,8 @@
 assert fail.identifier == 0
 assert self.cpu.get_int_value(deadframe, 0) == ord('g')
 
+@pytest.mark.xfail(sys.platform.startswith("openbsd"),
+   reason="something wrong with CDLL()")
 def test_call_to_c_function_with_callback(self):
 from rpython.rlib.libffi import CDLL, types, ArgChain, clibffi
 from rpython.rtyper.lltypesystem.ll2ctypes import libc_name
diff --git a/rpython/rlib/rdynload.py b/rpython/rlib/rdynload.py
--- a/rpython/rlib/rdynload.py
+++ b/rpython/rlib/rdynload.py
@@ -17,6 +17,7 @@
 _MAC_OS = platform.name == "darwin"
 _FREEBSD = sys.platform.startswith("freebsd")
 _NETBSD = sys.platform.startswith("netbsd")
+_OPENBSD = sys.platform.startswith("openbsd")
 
 if _WIN32:
 from rpython.rlib import rwin32
@@ -29,7 +30,7 @@
 else:
 pre_include_bits = []
 
-if _FREEBSD or _NETBSD or _WIN32:
+if _OPENBSD or _FREEBSD or _NETBSD or _WIN32:
 libraries = []
 else:
 libraries = ['dl']
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy asmmemmgr-for-code-only: Allocate mmap pages with PROT_NONE and provide ability to use mprotect.

2016-08-24 Thread vext01
Author: Edd Barrett 
Branch: asmmemmgr-for-code-only
Changeset: r86510:1425d9b5d850
Date: 2016-08-24 23:43 +0100
http://bitbucket.org/pypy/pypy/changeset/1425d9b5d850/

Log:Allocate mmap pages with PROT_NONE and provide ability to use
mprotect.

diff --git a/rpython/rlib/rmmap.py b/rpython/rlib/rmmap.py
--- a/rpython/rlib/rmmap.py
+++ b/rpython/rlib/rmmap.py
@@ -57,7 +57,7 @@
 # some constants are linux only so they will be correctly exposed outside
 # depending on the OS
 constant_names = ['MAP_SHARED', 'MAP_PRIVATE', 'MAP_FIXED',
-  'PROT_READ', 'PROT_WRITE',
+  'PROT_READ', 'PROT_WRITE', 'PROT_NONE',
   'MS_SYNC']
 opt_constant_names = ['MAP_ANON', 'MAP_ANONYMOUS', 'MAP_NORESERVE',
   'PROT_EXEC',
@@ -155,6 +155,10 @@
 c_mmap, c_mmap_safe = external('mmap', [PTR, size_t, rffi.INT, rffi.INT,
rffi.INT, off_t], PTR, macro=True,
save_err_on_unsafe=rffi.RFFI_SAVE_ERRNO)
+
+_, c_mprotect_safe = external('mprotect', [PTR, size_t, rffi.INT],
+  rffi.INT, _nowrapper=True)
+
 # 'mmap' on linux32 is a macro that calls 'mmap64'
 _, c_munmap_safe = external('munmap', [PTR, size_t], rffi.INT)
 c_msync, _ = external('msync', [PTR, size_t, rffi.INT], rffi.INT,
@@ -172,6 +176,8 @@
 _get_allocation_granularity = _get_page_size = lambda: _pagesize
 
 elif _MS_WINDOWS:
+# XXX mprotect equivalent
+# XXX set_pages_executable/writable equivalent
 
 class ComplexCConfig:
 _compilation_info_ = CConfig._compilation_info_
@@ -707,12 +713,29 @@
 
 def alloc_hinted(hintp, map_size):
 flags = MAP_PRIVATE | MAP_ANONYMOUS
-prot = PROT_EXEC | PROT_READ | PROT_WRITE
+# Pages start with no permissions
+prot = PROT_NONE
 if we_are_translated():
 flags = NonConstant(flags)
 prot = NonConstant(prot)
 return c_mmap_safe(hintp, map_size, prot, flags, -1, 0)
 
+def mprotect(addr, size, prot):
+addr = rffi.cast(PTR, addr)
+size = rffi.cast(lltype.Unsigned, size)
+prot = rffi.cast(rffi.INT, prot)
+return c_mprotect_safe(addr, size, prot)
+
+def set_pages_executable(addr, size):
+rv = mprotect(addr, size, PROT_EXEC | PROT_READ)
+if rv < 0:
+debug.fatalerror_notb("set_pages_executable failed")
+
+def set_pages_writable(addr, size):
+rv = mprotect(addr, size, PROT_WRITE | PROT_READ)
+if rv < 0:
+debug.fatalerror_notb("set_pages_executable failed")
+
 def clear_large_memory_chunk_aligned(addr, map_size):
 addr = rffi.cast(PTR, addr)
 flags = MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy.org extradoc: update the values

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r779:6b11ddd2bc44
Date: 2016-08-24 21:42 +0200
http://bitbucket.org/pypy/pypy.org/changeset/6b11ddd2bc44/

Log:update the values

diff --git a/don1.html b/don1.html
--- a/don1.html
+++ b/don1.html
@@ -15,7 +15,7 @@
 
 

-   $64859 of $105000 (61.8%)
+   $64931 of $105000 (61.8%)


 
@@ -23,7 +23,7 @@
   
   This donation goes towards supporting Python 3 in 
PyPy.
   Current status:
-we have $5336 left
+we have $5400 left
   in the account. Read proposal
   
   
diff --git a/don4.html b/don4.html
--- a/don4.html
+++ b/don4.html
@@ -17,7 +17,7 @@
2nd call:

-   $30875 of $8 (38.6%)
+   $30891 of $8 (38.6%)


 
@@ -25,7 +25,7 @@
   
   This donation goes towards supporting the 
Transactional Memory in PyPy.
   Current status:
-we have $23528 left
+we have $23541 left
   in the account. Read proposal (2nd 
call)
   
   
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reverse-debugger: fix for the merge

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: reverse-debugger
Changeset: r86507:290549df34f4
Date: 2016-08-24 19:11 +0100
http://bitbucket.org/pypy/pypy/changeset/290549df34f4/

Log:fix for the merge

diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -171,11 +171,12 @@
 
 # 
 
+extra_return_text = None
+
 def cfunction_body(self):
-extra_return_text = None
 if self.db.reverse_debugger:
 from rpython.translator.revdb import gencsupp
-(extra_enter_text, extra_return_text) = (
+(extra_enter_text, self.extra_return_text) = (
 gencsupp.prepare_function(self))
 if extra_enter_text:
 yield extra_enter_text
@@ -219,8 +220,8 @@
 retval = self.expr(block.inputargs[0])
 if self.exception_policy != "exc_helper":
 yield 'RPY_DEBUG_RETURN();'
-if extra_return_text:
-yield extra_return_text
+if self.extra_return_text:
+yield self.extra_return_text
 yield 'return %s;' % retval
 return
 elif block.exitswitch is None:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reverse-debugger: Revert the changes to the boehm API: it's still possible to find

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: reverse-debugger
Changeset: r86508:91697c0a6b45
Date: 2016-08-24 19:12 +0100
http://bitbucket.org/pypy/pypy/changeset/91697c0a6b45/

Log:Revert the changes to the boehm API: it's still possible to find
machines with an old Boehm library installed, e.g. bencher4

diff --git a/rpython/translator/c/gc.py b/rpython/translator/c/gc.py
--- a/rpython/translator/c/gc.py
+++ b/rpython/translator/c/gc.py
@@ -236,7 +236,7 @@
 if sys.platform == 'win32':
 pass # yield 'assert(GC_all_interior_pointers == 0);'
 else:
-yield 'GC_set_all_interior_pointers(0);'
+yield 'GC_all_interior_pointers = 0;'
 yield 'boehm_gc_startup_code();'
 
 def get_real_weakref_type(self):
diff --git a/rpython/translator/c/src/mem.c b/rpython/translator/c/src/mem.c
--- a/rpython/translator/c/src/mem.c
+++ b/rpython/translator/c/src/mem.c
@@ -117,8 +117,8 @@
 void boehm_gc_startup_code(void)
 {
 GC_init();
-GC_set_finalizer_notifier(_gc_finalizer_notifier);
-GC_set_finalize_on_demand(1);
+GC_finalizer_notifier = _gc_finalizer_notifier;
+GC_finalize_on_demand = 1;
 GC_set_warn_proc(mem_boehm_ignore);
 }
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: sys_module.filesystemencoding is not wrapped

2016-08-24 Thread rlamy
Author: Ronan Lamy 
Branch: py3k
Changeset: r86506:e5e113c82242
Date: 2016-08-24 19:01 +0100
http://bitbucket.org/pypy/pypy/changeset/e5e113c82242/

Log:sys_module.filesystemencoding is not wrapped

diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -144,7 +144,7 @@
 # XXX the two lines above take a few seconds to run whenever
 # we initialize the space; for tests, use a simpler version
 from pypy.module.sys.interp_encoding import base_encoding
-self.filesystemencoding = space.wrap(base_encoding)
+self.filesystemencoding = base_encoding
 
 def flush_std_files(self, space):
 w_stdout = space.sys.getdictvalue(space, 'stdout')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reverse-debugger: hg merge default

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: reverse-debugger
Changeset: r86505:670d925b3853
Date: 2016-08-24 19:06 +0200
http://bitbucket.org/pypy/pypy/changeset/670d925b3853/

Log:hg merge default

diff too long, truncating to 2000 out of 15666 lines

diff --git a/dotviewer/graphparse.py b/dotviewer/graphparse.py
--- a/dotviewer/graphparse.py
+++ b/dotviewer/graphparse.py
@@ -85,10 +85,11 @@
 pass
 
 def splitline(line, re_word = re.compile(r'[^\s"]\S*|["]["]|["].*?[^\\]["]')):
+import ast
 result = []
 for word in re_word.findall(line):
 if word.startswith('"'):
-word = eval(word)
+word = ast.literal_eval(word)
 result.append(word)
 return result
 
diff --git a/include/PyPy.h b/include/PyPy.h
--- a/include/PyPy.h
+++ b/include/PyPy.h
@@ -2,7 +2,11 @@
 #define _PYPY_H_
 
 /* This header is meant to be included in programs that use PyPy as an
-   embedded library. */
+   embedded library.
+
+   NOTE: this is deprecated.  Instead, use cffi's embedding support:
+   http://cffi.readthedocs.org/en/latest/embedding.html
+*/
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/lib-python/2.7/test/test_hash.py b/lib-python/2.7/test/test_hash.py
--- a/lib-python/2.7/test/test_hash.py
+++ b/lib-python/2.7/test/test_hash.py
@@ -174,7 +174,7 @@
 
 class StringlikeHashRandomizationTests(HashRandomizationTests):
 if check_impl_detail(pypy=True):
-EMPTY_STRING_HASH = -1
+EMPTY_STRING_HASH = -2
 else:
 EMPTY_STRING_HASH = 0
 
diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -167,7 +167,7 @@
 else:
 return self.value
 
-def __buffer__(self):
+def __buffer__(self, flags):
 return buffer(self._buffer)
 
 def _get_b_base(self):
@@ -199,10 +199,13 @@
 return tp._alignmentofinstances()
 
 @builtinify
-def byref(cdata):
+def byref(cdata, offset=0):
 # "pointer" is imported at the end of this module to avoid circular
 # imports
-return pointer(cdata)
+ptr = pointer(cdata)
+if offset != 0:
+ptr._buffer[0] += offset
+return ptr
 
 def cdata_from_address(self, address):
 # fix the address: turn it into as unsigned, in case it's a negative number
diff --git a/lib_pypy/_pypy_winbase_build.py b/lib_pypy/_pypy_winbase_build.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_pypy_winbase_build.py
@@ -0,0 +1,91 @@
+# Note: uses the CFFI out-of-line ABI mode.  We can't use the API
+# mode because ffi.compile() needs to run the compiler, which
+# needs 'subprocess', which needs 'msvcrt' and '_subprocess',
+# which depend on '_pypy_winbase_cffi' already.
+#
+# Note that if you need to regenerate _pypy_winbase_cffi and
+# can't use a preexisting PyPy to do that, then running this
+# file should work as long as 'subprocess' is not imported
+# by cffi.  I had to hack in 'cffi._pycparser' to move an
+#'import subprocess' to the inside of a function.  (Also,
+# CPython+CFFI should work as well.)
+#
+# This module supports both msvcrt.py and _subprocess.py.
+
+from cffi import FFI
+
+ffi = FFI()
+
+ffi.set_source("_pypy_winbase_cffi", None)
+
+# -- MSVCRT --
+
+ffi.cdef("""
+typedef unsigned short wint_t;
+
+int _open_osfhandle(intptr_t osfhandle, int flags);
+intptr_t _get_osfhandle(int fd);
+int _setmode(int fd, int mode);
+int _locking(int fd, int mode, long nbytes);
+
+int _kbhit(void);
+int _getch(void);
+wint_t _getwch(void);
+int _getche(void);
+wint_t _getwche(void);
+int _putch(int);
+wint_t _putwch(wchar_t);
+int _ungetch(int);
+wint_t _ungetwch(wint_t);
+""")
+
+# -- SUBPROCESS --
+
+ffi.cdef("""
+typedef struct {
+DWORD  cb;
+char * lpReserved;
+char * lpDesktop;
+char * lpTitle;
+DWORD  dwX;
+DWORD  dwY;
+DWORD  dwXSize;
+DWORD  dwYSize;
+DWORD  dwXCountChars;
+DWORD  dwYCountChars;
+DWORD  dwFillAttribute;
+DWORD  dwFlags;
+WORD   wShowWindow;
+WORD   cbReserved2;
+LPBYTE lpReserved2;
+HANDLE hStdInput;
+HANDLE hStdOutput;
+HANDLE hStdError;
+} STARTUPINFO, *LPSTARTUPINFO;
+
+typedef struct {
+HANDLE hProcess;
+HANDLE hThread;
+DWORD  dwProcessId;
+DWORD  dwThreadId;
+} PROCESS_INFORMATION, *LPPROCESS_INFORMATION;
+
+DWORD WINAPI GetVersion(void);
+BOOL WINAPI CreatePipe(PHANDLE, PHANDLE, void *, DWORD);
+BOOL WINAPI CloseHandle(HANDLE);
+HANDLE WINAPI GetCurrentProcess(void);
+BOOL WINAPI DuplicateHandle(HANDLE, HANDLE, HANDLE, LPHANDLE,
+DWORD, BOOL, DWORD);
+BOOL WINAPI CreateProcessA(char *, char *, void *,
+   void *, BOOL, DWORD, char *,
+   char *, LPSTARTUPINFO, LPPROCESS_INFORMATION);
+DWORD WINAPI WaitForSingleObject(HANDLE, DWORD);
+BOOL WINAPI GetExitCodeProcess(HANDLE, LPDWORD);
+BOOL WINAPI TerminateProcess(HANDLE, UINT);
+HANDLE WINAPI GetStdHandle(DWORD);
+""")
+

[pypy-commit] pypy default: Improve the test: if x == -1 then int(-0.8) == 0, and the second part of

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86504:189373c314f3
Date: 2016-08-24 17:54 +0200
http://bitbucket.org/pypy/pypy/changeset/189373c314f3/

Log:Improve the test: if x == -1 then int(-0.8) == 0, and the second
part of the test would not be run at all

diff --git a/pypy/module/test_lib_pypy/test_resource.py 
b/pypy/module/test_lib_pypy/test_resource.py
--- a/pypy/module/test_lib_pypy/test_resource.py
+++ b/pypy/module/test_lib_pypy/test_resource.py
@@ -50,7 +50,7 @@
 resource.setrlimit(resource.RLIMIT_CPU, (x, y))
 # sometimes, x and y are very large (more than 53 bits).
 # for these huge values, int(float(x)) > x...
-xf = x + 0.2
-yf = y + 0.3
+xf = x + (0.2 if x >= 0 else -0.2)
+yf = y + (0.3 if y >= 0 else -0.3)
 if int(xf) == x and int(yf) == y:
 resource.setrlimit(resource.RLIMIT_CPU, (x, y))  # truncated to ints
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: update whatsnew

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2747:8ee16fdadf92
Date: 2016-08-24 17:34 +0200
http://bitbucket.org/cffi/cffi/changeset/8ee16fdadf92/

Log:update whatsnew

diff --git a/doc/source/cdef.rst b/doc/source/cdef.rst
--- a/doc/source/cdef.rst
+++ b/doc/source/cdef.rst
@@ -529,9 +529,7 @@
 the same version of CPython x.y).  However, the standard ``distutils``
 package will still produce a file called e.g.
 ``NAME.cpython-35m-x86_64-linux-gnu.so``.  You can manually rename it to
-``NAME.abi3.so``.  There are certainly other ways to compile the C code
-that produce directly the correct file name, but I know of no
-widely-used solution.
+``NAME.abi3.so``, or use setuptools version 26 or later.
 
 **ffibuilder.compile(tmpdir='.', verbose=False):**
 explicitly generate the .py or .c file,
diff --git a/doc/source/whatsnew.rst b/doc/source/whatsnew.rst
--- a/doc/source/whatsnew.rst
+++ b/doc/source/whatsnew.rst
@@ -6,6 +6,13 @@
 v1.8
 
 
+* CPython 3.x: experimental: the generated C extension modules now use
+  the "limited API", which means that, as a compiled .so/.dll, it should
+  work directly on any version of CPython >= 3.2.  The name produced by
+  distutils is still version-specific.  To get the version-independent
+  name, you can rename it manually to ``NAME.abi3.so``, or use the very
+  recent setuptools 26.
+
 * Removed the restriction that ``ffi.from_buffer()`` cannot be used on
   byte strings.  Now you can get a ``char *`` out of a byte string,
   which is valid as long as the string object is kept alive.  (But
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: remove double definition of cpyext C symbol

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3k
Changeset: r86503:31eb26fe8cfa
Date: 2016-08-24 17:17 +0200
http://bitbucket.org/pypy/pypy/changeset/31eb26fe8cfa/

Log:remove double definition of cpyext C symbol

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -516,7 +516,7 @@
 'PyObject_CallMethod', 'PyObject_CallFunctionObjArgs', 
'PyObject_CallMethodObjArgs',
 '_PyObject_CallFunction_SizeT', '_PyObject_CallMethod_SizeT',
 
-'PyObject_GetBuffer', 'PyBuffer_Release',
+'PyBuffer_Release',
 
 'PyCObject_FromVoidPtr', 'PyCObject_FromVoidPtrAndDesc', 
'PyCObject_AsVoidPtr',
 'PyCObject_GetDesc', 'PyCObject_Import', 'PyCObject_SetVoidPtr',
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: document commits to default up to July 15

2016-08-24 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r86502:2fe6d5f48eb5
Date: 2016-08-25 00:45 +1000
http://bitbucket.org/pypy/pypy/changeset/2fe6d5f48eb5/

Log:document commits to default up to July 15

diff --git a/pypy/doc/release-pypy2.7-v5.4.0.rst 
b/pypy/doc/release-pypy2.7-v5.4.0.rst
--- a/pypy/doc/release-pypy2.7-v5.4.0.rst
+++ b/pypy/doc/release-pypy2.7-v5.4.0.rst
@@ -59,14 +59,82 @@
 
 * New features:
 
+  * Add `sys.{get,set}dlopenflags`
+
+  * Improve CPython compatibility of 'is' for small and empty strings
+
+  * Support for rgc.FinalizerQueue in the Boehm garbage collector
+
+  * (RPython) support spawnv() if it is called in C `_spawnv` on windows
+
+  * Fill in more slots when creating a PyTypeObject from a W_TypeObject,
+like `__hex__`, `__sub__`, `__pow__`
+
+  * Copy CPython's logic more closely for `isinstance()` and
+`issubclass()` as well as `type.__instancecheck__()` and
+`type.__subclasscheck__()`
+
 * Bug Fixes
 
+  * Reject `mkdir()` in read-only sandbox filesystems
+
+  * Add include guards to pymem.h to enable c++ compilation
+
+  * Fix OpenBSD build breakage and support OpenBSD in VMProf.
+
+  * Fix for `bytearray('').replace('a', 'ab')` for empty strings
+
+  * Sync internal state before calling `PyFile_AsFile()`
+
+  * Allow writing to a char* from `PyString_AsString()` until it is
+forced, also refactor `PyStringObject` to look like CPython's
+and allow subclassing `PyString_Type` and `PyUnicode_Type`
+
+  * Rpython rffi's socket(2) wrapper did not preserve errno
+
+  * Refactor `PyTupleObject` to look like CPython's and allow
+subclassing `PyTuple_Type`
+
+  * Allow c-level assignment to a function pointer in a C-API
+user-defined type after calling PyTypeReady by retrieving
+a pointer to the function via offsets
+rather than storing the function pointer itself
+
+  * Use `madvise(MADV_FREE)`, or if that doesn't exist
+`MADV_DONTNEED` on freed arenas to release memory back to the
+OS for resource monitoring
+
   * Issues reported with our previous release were resolved_ after
 reports from users on our issue tracker at
 https://bitbucket.org/pypy/pypy/issues or on IRC at #pypy
 
 * Performance improvements:
 
+  * Add a before_call()-like equivalent before a few operations like
+   `malloc_nursery`, to move values from registers into other registers
+instead of to the stack.
+
+  * More tightly pack the stack when calling with `release gil`
+
+  * Support `int_floordiv()`, `int_mod()` in the JIT more efficiently
+and add `rarithmetic.int_c_div()`, `rarithmetic.int_c_mod()` as
+explicit interfaces. Clarify that `int_floordiv()` does python-style
+rounding, unlike `llop.int_floordiv()`.
+
+  * Use `ll_assert` (more often) in incminimark
+
+  * (Testing) Simplify handling of interp-level tests and make it
+more forward-compatible. Don't use interp-level RPython
+machinery to test building app-level extensions in cpyext
+
+  * Constant-fold `ffi.offsetof("structname", "fieldname")` in cffi
+backend
+
+  * Avoid a case in the JIT, where successive guard failures in
+the same Python function end up as successive levels of
+RPython functions, eventually exhausting the stack, while at
+app-level the traceback is very short
+
 .. _resolved: http://doc.pypy.org/en/latest/whatsnew-5.3.0.html
 
 Please update, and continue to help us make PyPy better.
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: (cfbolz, arigo)

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86500:123020cd1730
Date: 2016-08-24 15:47 +0100
http://bitbucket.org/pypy/pypy/changeset/123020cd1730/

Log:(cfbolz, arigo)

Add a hypothesis-based test for creating and changing attributes on
a class or on an instance (regular attributes, slots, methods, etc.)

diff --git a/pypy/objspace/std/test/test_random_attr.py 
b/pypy/objspace/std/test/test_random_attr.py
new file mode 100644
--- /dev/null
+++ b/pypy/objspace/std/test/test_random_attr.py
@@ -0,0 +1,131 @@
+import pytest
+import sys
+from hypothesis import given, strategies, settings
+from pypy.tool.pytest.objspace import gettestobjspace
+
+base_initargs = strategies.sampled_from([
+("object", (), False),
+("type(sys)", ("fake", ), True),
+("NewBase", (), True),
+("OldBase", (), False),
+("object, OldBase", (), False),
+("type(sys), OldBase", ("fake", ), True),
+])
+
+attrnames = strategies.sampled_from(["a", "b", "c"])
+
+@strategies.composite
+def make_code(draw):
+# now here we can do this kind of thing:
+baseclass, initargs, hasdict = draw(base_initargs)
+# and with arbitrary strategies
+
+def class_attr():
+what = draw(strategies.sampled_from(["value", "method", "property"]))
+if what == "value":
+val = draw(strategies.integers())
+return val, str(val)
+if what == "method":
+val = draw(strategies.integers())
+return (lambda self, val=val: val,
+"lambda self: %d" % val)
+if what == "property":
+val = draw(strategies.integers())
+return (property(lambda self, val=val: val,
+ lambda self, val: None,
+ lambda self: None),
+"property(lambda self: %d, lambda self, val: None, lambda 
self: None)" % val)
+
+code = ["import sys", "class OldBase:pass", "class NewBase(object):pass", 
"class A(%s):" % baseclass]
+dct = {}
+if draw(strategies.booleans()):
+slots = draw(strategies.lists(attrnames))
+if not hasdict and draw(strategies.booleans()):
+slots.append("__dict__")
+dct["__slots__"] = slots
+code.append("__slots__ = %s" % (slots, ))
+for name in ["a", "b", "c"]:
+if not draw(strategies.booleans()):
+continue
+dct[name], codeval = class_attr()
+code.append("%s = %s" % (name, codeval))
+class OldBase: pass
+class NewBase(object): pass
+evaldct = {'OldBase': OldBase, 'NewBase': NewBase}
+if baseclass == 'OldBase':
+metaclass = type(OldBase)
+else:
+metaclass = type
+cls = metaclass("A", eval(baseclass+',', globals(), evaldct), dct)
+inst = cls(*initargs)
+code.append("pass")
+code.append("a = A(*%s)" % (initargs, ))
+for attr in draw(strategies.lists(attrnames, min_size=1)):
+op = draw(strategies.sampled_from(["read", "read", "read",
+  "write", "writemeth", "writeclass", "writebase",
+  "del", "delclass"]))
+if op == "read":
+try:
+res = getattr(inst, attr)
+except AttributeError:
+code.append("raises(AttributeError, 'a.%s')" % (attr, ))
+else:
+if callable(res):
+code.append("assert a.%s() == %s" % (attr, res()))
+else:
+code.append("assert a.%s == %s" % (attr, res))
+elif op == "write":
+val = draw(strategies.integers())
+try:
+setattr(inst, attr, val)
+except AttributeError:
+code.append("raises(AttributeError, 'a.%s=%s')" % (attr, val))
+else:
+code.append("a.%s = %s" % (attr, val))
+elif op == "writemeth":
+val = draw(strategies.integers())
+try:
+setattr(inst, attr, lambda val=val: val)
+except AttributeError:
+code.append("raises(AttributeError, 'a.%s=0')" % (attr, ))
+else:
+code.append("a.%s = lambda : %s" % (attr, val))
+elif op == "writeclass":
+val, codeval = class_attr()
+setattr(cls, attr, val)
+code.append("A.%s = %s" % (attr, codeval))
+elif op == "writebase":
+val, codeval = class_attr()
+setattr(OldBase, attr, val)
+setattr(NewBase, attr, val)
+code.append("OldBase.%s = NewBase.%s = %s" % (attr, attr , 
codeval))
+elif op == "del":
+try:
+delattr(inst, attr)
+except AttributeError:
+code.append("raises(AttributeError, 'del a.%s')" % (attr, ))
+else:
+code.append("del a.%s" % (attr, ))
+elif op == "delclass":
+try:
+delattr(cls, attr)
+ 

[pypy-commit] pypy default: merge heads

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86501:145e67b3b78a
Date: 2016-08-24 15:48 +0100
http://bitbucket.org/pypy/pypy/changeset/145e67b3b78a/

Log:merge heads

diff --git a/pypy/doc/index-of-release-notes.rst 
b/pypy/doc/index-of-release-notes.rst
--- a/pypy/doc/index-of-release-notes.rst
+++ b/pypy/doc/index-of-release-notes.rst
@@ -6,6 +6,7 @@
 
 .. toctree::
 
+   release-pypy2.7-v5.4.0.rst
release-pypy2.7-v5.3.1.rst
release-pypy2.7-v5.3.0.rst
release-5.1.1.rst
diff --git a/pypy/doc/release-pypy2.7-v5.4.0.rst 
b/pypy/doc/release-pypy2.7-v5.4.0.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/release-pypy2.7-v5.4.0.rst
@@ -0,0 +1,74 @@
+
+PyPy2.7 v5.4
+
+
+We have released PyPy2.7 v5.4, a little under two months after PyPy2.7 v5.3.
+This new PyPy2.7 release includes further improvements to our C-API 
compatability layer (cpyext), enabling us to pass over 99% of the upstream
+numpy `test suite`_. We updated built-in cffi_ support to version 1.8,
+and fixed many issues and bugs raised by the growing community of PyPy
+users.
+
+X MORE ???
+
+You can download the PyPy2.7 v5.4 release here:
+
+http://pypy.org/download.html
+
+We would like to thank our donors for the continued support of the PyPy
+project.
+
+We would also like to thank our contributors and
+encourage new people to join the project. PyPy has many
+layers and we need help with all of them: `PyPy`_ and `RPython`_ documentation
+improvements, tweaking popular `modules`_ to run on pypy, or general `help`_
+with making RPython's JIT even better.
+
+.. _`test suite`: 
https://bitbucket.org/pypy/pypy/wiki/Adventures%20in%20cpyext%20compatibility
+.. _cffi: https://cffi.readthedocs.org
+.. _`PyPy`: http://doc.pypy.org
+.. _`RPython`: https://rpython.readthedocs.org
+.. _`modules`: 
http://doc.pypy.org/en/latest/project-ideas.html#make-more-python-modules-pypy-friendly
+.. _`help`: http://doc.pypy.org/en/latest/project-ideas.html
+
+What is PyPy?
+=
+
+PyPy is a very compliant Python interpreter, almost a drop-in replacement for
+CPython 2.7. It's fast (`PyPy and CPython 2.7.x`_ performance comparison)
+due to its integrated tracing JIT compiler.
+
+We also welcome developers of other `dynamic languages`_ to see what RPython
+can do for them.
+
+This release supports: 
+
+  * **x86** machines on most common operating systems
+(Linux 32/64 bits, Mac OS X 64 bits, Windows 32 bits, OpenBSD, FreeBSD)
+  
+  * newer **ARM** hardware (ARMv6 or ARMv7, with VFPv3) running Linux,
+  
+  * big- and little-endian variants of **PPC64** running Linux,
+
+  * **s390x** running Linux
+
+.. _`PyPy and CPython 2.7.x`: http://speed.pypy.org
+.. _`dynamic languages`: http://pypyjs.org
+
+Other Highlights (since 5.3 released in June 2016)
+=
+
+* New features:
+
+* Bug Fixes
+
+  * Issues reported with our previous release were resolved_ after
+reports from users on our issue tracker at
+https://bitbucket.org/pypy/pypy/issues or on IRC at #pypy
+
+* Performance improvements:
+
+.. _resolved: http://doc.pypy.org/en/latest/whatsnew-5.3.0.html
+
+Please update, and continue to help us make PyPy better.
+
+Cheers
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: (arigo, cfbolz): logic was inverted (bad cfbolz, no cookie)

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86499:2cd8ca921907
Date: 2016-08-24 14:43 +0100
http://bitbucket.org/pypy/pypy/changeset/2cd8ca921907/

Log:(arigo, cfbolz): logic was inverted (bad cfbolz, no cookie)

diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -1018,7 +1018,7 @@
 # if the layout has a dict itself, then mapdict is not used for normal
 # attributes. Then the cache won't be able to spot changes to the dict.
 # Thus we don't cache. see test_bug_builtin_types_callmethod
-if not w_type.layout.typedef.hasdict:
+if w_type.layout.typedef.hasdict:
 return
 
 if w_method is None or isinstance(w_method, MutableCell):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: missing import

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3k
Changeset: r86498:d711ffd606f3
Date: 2016-08-24 16:35 +0200
http://bitbucket.org/pypy/pypy/changeset/d711ffd606f3/

Log:missing import

diff --git a/pypy/module/cpyext/buffer.py b/pypy/module/cpyext/buffer.py
--- a/pypy/module/cpyext/buffer.py
+++ b/pypy/module/cpyext/buffer.py
@@ -3,7 +3,7 @@
 from rpython.rlib import buffer
 from pypy.module.cpyext.api import (
 cpython_api, CANNOT_FAIL, Py_buffer)
-from pypy.module.cpyext.pyobject import PyObject
+from pypy.module.cpyext.pyobject import PyObject, Py_DecRef
 
 @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
 def PyObject_CheckBuffer(space, w_obj):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: start release notes

2016-08-24 Thread mattip
Author: Matti Picus 
Branch: 
Changeset: r86497:0b1493214116
Date: 2016-08-24 23:30 +1000
http://bitbucket.org/pypy/pypy/changeset/0b1493214116/

Log:start release notes

diff --git a/pypy/doc/index-of-release-notes.rst 
b/pypy/doc/index-of-release-notes.rst
--- a/pypy/doc/index-of-release-notes.rst
+++ b/pypy/doc/index-of-release-notes.rst
@@ -6,6 +6,7 @@
 
 .. toctree::
 
+   release-pypy2.7-v5.4.0.rst
release-pypy2.7-v5.3.1.rst
release-pypy2.7-v5.3.0.rst
release-5.1.1.rst
diff --git a/pypy/doc/release-pypy2.7-v5.4.0.rst 
b/pypy/doc/release-pypy2.7-v5.4.0.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/release-pypy2.7-v5.4.0.rst
@@ -0,0 +1,74 @@
+
+PyPy2.7 v5.4
+
+
+We have released PyPy2.7 v5.4, a little under two months after PyPy2.7 v5.3.
+This new PyPy2.7 release includes further improvements to our C-API 
compatability layer (cpyext), enabling us to pass over 99% of the upstream
+numpy `test suite`_. We updated built-in cffi_ support to version 1.8,
+and fixed many issues and bugs raised by the growing community of PyPy
+users.
+
+X MORE ???
+
+You can download the PyPy2.7 v5.4 release here:
+
+http://pypy.org/download.html
+
+We would like to thank our donors for the continued support of the PyPy
+project.
+
+We would also like to thank our contributors and
+encourage new people to join the project. PyPy has many
+layers and we need help with all of them: `PyPy`_ and `RPython`_ documentation
+improvements, tweaking popular `modules`_ to run on pypy, or general `help`_
+with making RPython's JIT even better.
+
+.. _`test suite`: 
https://bitbucket.org/pypy/pypy/wiki/Adventures%20in%20cpyext%20compatibility
+.. _cffi: https://cffi.readthedocs.org
+.. _`PyPy`: http://doc.pypy.org
+.. _`RPython`: https://rpython.readthedocs.org
+.. _`modules`: 
http://doc.pypy.org/en/latest/project-ideas.html#make-more-python-modules-pypy-friendly
+.. _`help`: http://doc.pypy.org/en/latest/project-ideas.html
+
+What is PyPy?
+=
+
+PyPy is a very compliant Python interpreter, almost a drop-in replacement for
+CPython 2.7. It's fast (`PyPy and CPython 2.7.x`_ performance comparison)
+due to its integrated tracing JIT compiler.
+
+We also welcome developers of other `dynamic languages`_ to see what RPython
+can do for them.
+
+This release supports: 
+
+  * **x86** machines on most common operating systems
+(Linux 32/64 bits, Mac OS X 64 bits, Windows 32 bits, OpenBSD, FreeBSD)
+  
+  * newer **ARM** hardware (ARMv6 or ARMv7, with VFPv3) running Linux,
+  
+  * big- and little-endian variants of **PPC64** running Linux,
+
+  * **s390x** running Linux
+
+.. _`PyPy and CPython 2.7.x`: http://speed.pypy.org
+.. _`dynamic languages`: http://pypyjs.org
+
+Other Highlights (since 5.3 released in June 2016)
+=
+
+* New features:
+
+* Bug Fixes
+
+  * Issues reported with our previous release were resolved_ after
+reports from users on our issue tracker at
+https://bitbucket.org/pypy/pypy/issues or on IRC at #pypy
+
+* Performance improvements:
+
+.. _resolved: http://doc.pypy.org/en/latest/whatsnew-5.3.0.html
+
+Please update, and continue to help us make PyPy better.
+
+Cheers
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy cpyext-subclass: add failing test for subclass with tp_as_number methods

2016-08-24 Thread mattip
Author: Matti Picus 
Branch: cpyext-subclass
Changeset: r86496:bbc135100879
Date: 2016-08-24 23:10 +1000
http://bitbucket.org/pypy/pypy/changeset/bbc135100879/

Log:add failing test for subclass with tp_as_number methods

diff --git a/pypy/module/cpyext/test/test_arraymodule.py 
b/pypy/module/cpyext/test/test_arraymodule.py
--- a/pypy/module/cpyext/test/test_arraymodule.py
+++ b/pypy/module/cpyext/test/test_arraymodule.py
@@ -87,4 +87,13 @@
 module.switch_multiply()
 res = [1, 2, 3] * arr
 assert res == [2, 4, 6]
+
+def test_subclass(self):
+module = self.import_module(name='array')
+class Sub(module.array):
+pass
+
+arr = Sub('i', [2])
+res = [1, 2, 3] * arr
+assert res == [1, 2, 3, 1, 2, 3]
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the result type of _winreg.QueryValueEx() for REG_SZ or

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86493:eaf0960e857d
Date: 2016-08-24 14:32 +0200
http://bitbucket.org/pypy/pypy/changeset/eaf0960e857d/

Log:Fix the result type of _winreg.QueryValueEx() for REG_SZ or
REG_EXPAND_SZ keys

diff --git a/pypy/module/_winreg/interp_winreg.py 
b/pypy/module/_winreg/interp_winreg.py
--- a/pypy/module/_winreg/interp_winreg.py
+++ b/pypy/module/_winreg/interp_winreg.py
@@ -358,9 +358,15 @@
 
 elif typ == rwinreg.REG_SZ or typ == rwinreg.REG_EXPAND_SZ:
 if not buflen:
-return space.wrap("")
-s = rffi.charp2strn(rffi.cast(rffi.CCHARP, buf), buflen)
-return space.wrap(s)
+s = ""
+else:
+# may or may not have a trailing NULL in the buffer.
+buf = rffi.cast(rffi.CCHARP, buf)
+if buf[buflen - 1] == '\x00':
+buflen -= 1
+s = rffi.charp2strn(buf, buflen)
+w_s = space.wrap(s)
+return space.call_method(w_s, 'decode', space.wrap('mbcs'))
 
 elif typ == rwinreg.REG_MULTI_SZ:
 if not buflen:
@@ -460,7 +466,7 @@
 return space.newtuple([
 convert_from_regdata(space, databuf,
  length, retType[0]),
-space.wrap(retType[0]),
+space.wrap(intmask(retType[0])),
 ])
 
 @unwrap_spec(subkey=str)
@@ -612,7 +618,7 @@
 space.wrap(rffi.charp2str(valuebuf)),
 convert_from_regdata(space, databuf,
  length, retType[0]),
-space.wrap(retType[0]),
+space.wrap(intmask(retType[0])),
 ])
 
 @unwrap_spec(index=int)
diff --git a/pypy/module/_winreg/test/test_winreg.py 
b/pypy/module/_winreg/test/test_winreg.py
--- a/pypy/module/_winreg/test/test_winreg.py
+++ b/pypy/module/_winreg/test/test_winreg.py
@@ -151,6 +151,7 @@
 
 def test_readValues(self):
 from _winreg import OpenKey, EnumValue, QueryValueEx, EnumKey
+from _winreg import REG_SZ, REG_EXPAND_SZ
 key = OpenKey(self.root_key, self.test_key_name)
 sub_key = OpenKey(key, "sub_key")
 index = 0
@@ -164,7 +165,10 @@
 assert index == len(self.test_data)
 
 for name, value, type in self.test_data:
-assert QueryValueEx(sub_key, name) == (value, type)
+result = QueryValueEx(sub_key, name)
+assert result == (value, type)
+if type == REG_SZ or type == REG_EXPAND_SZ:
+assert isinstance(result[0], unicode) # not string
 
 assert EnumKey(key, 0) == "sub_key"
 raises(EnvironmentError, EnumKey, key, 1)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: add the equivalent test for LOAD_ATTR. that already works, update the comment

2016-08-24 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: 
Changeset: r86492:c25842df0d7d
Date: 2016-08-24 11:51 +0100
http://bitbucket.org/pypy/pypy/changeset/c25842df0d7d/

Log:add the equivalent test for LOAD_ATTR. that already works, update
the comment explaining why

diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -992,7 +992,8 @@
 if index != INVALID:
 attr = map.find_map_attr(attrname, index)
 if attr is not None:
-# Note that if map.terminator is a DevolvedDictTerminator,
+# Note that if map.terminator is a DevolvedDictTerminator
+# or the class provides its own dict, not using mapdict, 
then:
 # map.find_map_attr will always return None if index==DICT.
 _fill_cache(pycode, nameindex, map, version_tag, 
attr.storageindex)
 return w_obj._mapdict_read_storage(attr.storageindex)
diff --git a/pypy/objspace/std/test/test_mapdict.py 
b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -1233,6 +1233,25 @@
 assert res1 == "mymethod"
 assert res2 == "foobar"
 
+def test_bug_builtin_types_load_attr(self):
+import sys
+class D(type(sys)):
+def mymethod(self):
+return "mymethod"
+
+def foobar():
+return "foobar"
+
+d = D('d')
+m = d.mymethod
+res1 = m()
+d.mymethod = foobar
+m = d.mymethod
+res2 = m()
+assert res1 == "mymethod"
+assert res2 == "foobar"
+
+
 
 class AppTestGlobalCaching(AppTestWithMapDict):
 spaceconfig = {"objspace.std.withmethodcachecounter": True}
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: (cfbolz, arigo): fix the mapdict cache for subclasses of builtin types that

2016-08-24 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: 
Changeset: r86491:46e88ff9f92f
Date: 2016-08-24 11:42 +0100
http://bitbucket.org/pypy/pypy/changeset/46e88ff9f92f/

Log:(cfbolz, arigo): fix the mapdict cache for subclasses of builtin
types that provide a dict

diff --git a/pypy/objspace/std/mapdict.py b/pypy/objspace/std/mapdict.py
--- a/pypy/objspace/std/mapdict.py
+++ b/pypy/objspace/std/mapdict.py
@@ -1014,6 +1014,12 @@
 
 def LOOKUP_METHOD_mapdict_fill_cache_method(space, pycode, name, nameindex,
 w_obj, w_type, w_method):
+# if the layout has a dict itself, then mapdict is not used for normal
+# attributes. Then the cache won't be able to spot changes to the dict.
+# Thus we don't cache. see test_bug_builtin_types_callmethod
+if not w_type.layout.typedef.hasdict:
+return
+
 if w_method is None or isinstance(w_method, MutableCell):
 # don't cache the MutableCell XXX could be fixed
 return
diff --git a/pypy/objspace/std/test/test_mapdict.py 
b/pypy/objspace/std/test/test_mapdict.py
--- a/pypy/objspace/std/test/test_mapdict.py
+++ b/pypy/objspace/std/test/test_mapdict.py
@@ -1217,6 +1217,23 @@
 got = x.a
 assert got == 'd'
 
+def test_bug_builtin_types_callmethod(self):
+import sys
+class D(type(sys)):
+def mymethod(self):
+return "mymethod"
+
+def foobar():
+return "foobar"
+
+d = D('d')
+res1 = d.mymethod()
+d.mymethod = foobar
+res2 = d.mymethod()
+assert res1 == "mymethod"
+assert res2 == "foobar"
+
+
 class AppTestGlobalCaching(AppTestWithMapDict):
 spaceconfig = {"objspace.std.withmethodcachecounter": True}
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: Added issue #2375 here, for py3.5.

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r5682:7dd8cae2a466
Date: 2016-08-24 12:21 +0200
http://bitbucket.org/pypy/extradoc/changeset/7dd8cae2a466/

Log:Added issue #2375 here, for py3.5.

diff --git a/planning/py3.5/2016-august-progress.rst 
b/planning/py3.5/2016-august-progress.rst
--- a/planning/py3.5/2016-august-progress.rst
+++ b/planning/py3.5/2016-august-progress.rst
@@ -34,6 +34,8 @@
   adding gi_yieldfrom/cr_await to generator/coroutines.  (Waiting
   because some work might be going on with raffael_t.)
 
+* compare ``dir(posix)`` on py3.5 and cpython 3.5.
+
 
 Milestone 1 (Aug-Sep-Oct 2016)
 --
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: missing import

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3k
Changeset: r86490:608a0ce136ed
Date: 2016-08-24 12:21 +0200
http://bitbucket.org/pypy/pypy/changeset/608a0ce136ed/

Log:missing import

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
@@ -20,6 +20,7 @@
 from rpython.rlib.buffer import Buffer
 from rpython.rlib.unroll import unrolling_iterable
 from rpython.rlib.objectmodel import specialize
+from rpython.rlib.rarithmetic import widen
 from rpython.tool.sourcetools import func_renamer
 from rpython.rtyper.annlowlevel import llhelper
 from pypy.module.sys.version import CPYTHON_VERSION
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy closed-branches: Merge closed head 9f7d18f5d82f on branch refactor_rmmap

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: closed-branches
Changeset: r86483:17571d1796fc
Date: 2016-08-24 12:15 +0200
http://bitbucket.org/pypy/pypy/changeset/17571d1796fc/

Log:Merge closed head 9f7d18f5d82f on branch refactor_rmmap

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy closed-branches: Merge closed head f07260687448 on branch rpython-deque

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: closed-branches
Changeset: r86484:31648ede1a09
Date: 2016-08-24 12:15 +0200
http://bitbucket.org/pypy/pypy/changeset/31648ede1a09/

Log:Merge closed head f07260687448 on branch rpython-deque

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy closed-branches: Merge closed head 62431e382e83 on branch use-mmap

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: closed-branches
Changeset: r86486:b4b42e343205
Date: 2016-08-24 12:15 +0200
http://bitbucket.org/pypy/pypy/changeset/b4b42e343205/

Log:Merge closed head 62431e382e83 on branch use-mmap

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy closed-branches: Merge closed head bf922c1461c7 on branch save_socket_errno

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: closed-branches
Changeset: r86488:42285066ce04
Date: 2016-08-24 12:15 +0200
http://bitbucket.org/pypy/pypy/changeset/42285066ce04/

Log:Merge closed head bf922c1461c7 on branch save_socket_errno

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy closed-branches: re-close this branch

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: closed-branches
Changeset: r86489:2dbecd2a45b0
Date: 2016-08-24 12:15 +0200
http://bitbucket.org/pypy/pypy/changeset/2dbecd2a45b0/

Log:re-close this branch

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy closed-branches: Merge closed head 9ac7d2defab0 on branch memoryview-attributes

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: closed-branches
Changeset: r86485:d129717390db
Date: 2016-08-24 12:15 +0200
http://bitbucket.org/pypy/pypy/changeset/d129717390db/

Log:Merge closed head 9ac7d2defab0 on branch memoryview-attributes

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy save_socket_errno: close merged branch

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: save_socket_errno
Changeset: r86479:bf922c1461c7
Date: 2016-08-24 12:14 +0200
http://bitbucket.org/pypy/pypy/changeset/bf922c1461c7/

Log:close merged branch

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy issue2335: close merged branch

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: issue2335
Changeset: r86478:68b03c738401
Date: 2016-08-24 12:13 +0200
http://bitbucket.org/pypy/pypy/changeset/68b03c738401/

Log:close merged branch

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy closed-branches: Merge closed head c327a2fa5f02 on branch new-jit-log

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: closed-branches
Changeset: r86481:ed4389f7bf97
Date: 2016-08-24 12:15 +0200
http://bitbucket.org/pypy/pypy/changeset/ed4389f7bf97/

Log:Merge closed head c327a2fa5f02 on branch new-jit-log

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy closed-branches: Merge closed head ca83cb5287e7 on branch fix-gen-dfa

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: closed-branches
Changeset: r86480:c615391e9bc0
Date: 2016-08-24 12:15 +0200
http://bitbucket.org/pypy/pypy/changeset/c615391e9bc0/

Log:Merge closed head ca83cb5287e7 on branch fix-gen-dfa

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy closed-branches: Merge closed head 2569ef7fa3cc on branch py3.5-async-translate

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: closed-branches
Changeset: r86482:295f6f8fd710
Date: 2016-08-24 12:15 +0200
http://bitbucket.org/pypy/pypy/changeset/295f6f8fd710/

Log:Merge closed head 2569ef7fa3cc on branch py3.5-async-translate

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy closed-branches: Merge closed head 68b03c738401 on branch issue2335

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: closed-branches
Changeset: r86487:490d2b04d53c
Date: 2016-08-24 12:15 +0200
http://bitbucket.org/pypy/pypy/changeset/490d2b04d53c/

Log:Merge closed head 68b03c738401 on branch issue2335

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy use-mmap: Superceded by use-madv-free

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: use-mmap
Changeset: r86477:62431e382e83
Date: 2016-08-24 12:12 +0200
http://bitbucket.org/pypy/pypy/changeset/62431e382e83/

Log:Superceded by use-madv-free

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5-memoryview: merge py3.5

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5-memoryview
Changeset: r86476:9955cc83a3a8
Date: 2016-08-24 12:00 +0200
http://bitbucket.org/pypy/pypy/changeset/9955cc83a3a8/

Log:merge py3.5

diff --git a/lib_pypy/_pypy_interact.py b/lib_pypy/_pypy_interact.py
--- a/lib_pypy/_pypy_interact.py
+++ b/lib_pypy/_pypy_interact.py
@@ -49,9 +49,11 @@
 if mainmodule is None:
 import __main__ as mainmodule
 console = code.InteractiveConsole(mainmodule.__dict__, filename='')
-# some parts of code.py are copied here because it seems to be impossible
+# some parts of code.py are copied here because it was impossible
 # to start an interactive console without printing at least one line
-# of banner
+# of banner.  This was fixed in 3.4; but then from 3.6 it prints a
+# line when exiting.  This can be disabled too---by passing an argument
+# that doesn't exist in <= 3.5.  So, too much mess: just copy the code.
 more = 0
 while 1:
 try:
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
@@ -11,7 +11,7 @@
 getattrfunc, getattrofunc, setattrofunc, lenfunc, ssizeargfunc, inquiry,
 ssizessizeargfunc, ssizeobjargproc, iternextfunc, initproc, richcmpfunc,
 cmpfunc, hashfunc, descrgetfunc, descrsetfunc, objobjproc, objobjargproc,
-getbufferproc, readbufferproc, ssizessizeobjargproc)
+getbufferproc, ssizessizeobjargproc)
 from pypy.module.cpyext.pyobject import from_ref, make_ref, Py_DecRef
 from pypy.module.cpyext.pyerrors import PyErr_Occurred
 from pypy.module.cpyext.state import State
@@ -22,6 +22,9 @@
 from rpython.rlib.objectmodel import specialize
 from rpython.tool.sourcetools import func_renamer
 from rpython.rtyper.annlowlevel import llhelper
+from pypy.module.sys.version import CPYTHON_VERSION
+
+PY3 = CPYTHON_VERSION[0] == 3
 
 # XXX: Also defined in object.h
 Py_LT = 0
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -14,7 +14,7 @@
 from pypy.module.cpyext import structmemberdefs
 from pypy.module.cpyext.api import (
 cpython_api, cpython_struct, bootstrap_function, Py_ssize_t, Py_ssize_tP,
-generic_cpy_call, Py_TPFLAGS_READY, Py_TPFLAGS_READYING,
+generic_cpy_call, Py_TPFLAGS_READY, Py_TPFLAGS_READYING, Py_buffer,
 Py_TPFLAGS_HEAPTYPE, METH_VARARGS, METH_KEYWORDS, CANNOT_FAIL,
 Py_TPFLAGS_HAVE_GETCHARBUFFER, build_type_checkers, StaticObjectBuilder,
 PyObjectFields, Py_TPFLAGS_BASETYPE, PyTypeObject, PyTypeObjectPtr,
diff --git a/pypy/module/cpyext/typeobjectdefs.py 
b/pypy/module/cpyext/typeobjectdefs.py
--- a/pypy/module/cpyext/typeobjectdefs.py
+++ b/pypy/module/cpyext/typeobjectdefs.py
@@ -1,7 +1,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rtyper.lltypesystem.lltype import Ptr, FuncType, Void
 from pypy.module.cpyext.api import (cpython_struct, Py_ssize_t, Py_ssize_tP,
-PyVarObjectFields, PyTypeObject, PyTypeObjectPtr, FILEP, Py_Buffer,
+PyVarObjectFields, PyTypeObject, PyTypeObjectPtr, FILEP, Py_buffer,
 Py_TPFLAGS_READYING, Py_TPFLAGS_READY, Py_TPFLAGS_HEAPTYPE)
 from pypy.module.cpyext.pyobject import PyObject, make_ref, from_ref
 from pypy.module.cpyext.modsupport import PyMethodDef
@@ -54,10 +54,6 @@
 wrapperfunc = P(FT([PyO, PyO, rffi.VOIDP], PyO))
 wrapperfunc_kwds = P(FT([PyO, PyO, rffi.VOIDP, PyO], PyO))
 
-readbufferproc = P(FT([PyO, Py_ssize_t, rffi.VOIDPP], Py_ssize_t))
-writebufferproc = P(FT([PyO, Py_ssize_t, rffi.VOIDPP], Py_ssize_t))
-segcountproc = P(FT([PyO, Py_ssize_tP], Py_ssize_t))
-charbufferproc = P(FT([PyO, Py_ssize_t, rffi.CCHARPP], Py_ssize_t))
 getbufferproc = P(FT([PyO, Py_bufferP, rffi.INT_real], rffi.INT_real))
 releasebufferproc = P(FT([PyO, Py_bufferP], Void))
 
@@ -131,10 +127,6 @@
 ))
 
 PyBufferProcs = cpython_struct("PyBufferProcs", (
-("bf_getreadbuffer", readbufferproc),
-("bf_getwritebuffer", writebufferproc),
-("bf_getsegcount", segcountproc),
-("bf_getcharbuffer", charbufferproc),
 ("bf_getbuffer", getbufferproc),
 ("bf_releasebuffer", releasebufferproc),
 ))
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -394,13 +394,6 @@
 of the specified width. The string S is never truncated.
 """
 
-def descr_hex(self, space):
-"""S.hex() -> string
-
-Creates a hexadecimal string of the bytes object
-"""
-
-
 class W_BytesObject(W_AbstractBytesObject):
 import_from_mixin(StringMethods)
 _immutable_fields_ = ['_value']
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -223,7 +223,7 @@
 pass
 
 if _WIN32:
-includes = ['io.h', 'sys/utime.h', 

[pypy-commit] pypy py3.5: merge py3k

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r86475:a43d6aa79232
Date: 2016-08-24 11:59 +0200
http://bitbucket.org/pypy/pypy/changeset/a43d6aa79232/

Log:merge py3k

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
@@ -11,7 +11,7 @@
 getattrfunc, getattrofunc, setattrofunc, lenfunc, ssizeargfunc, inquiry,
 ssizessizeargfunc, ssizeobjargproc, iternextfunc, initproc, richcmpfunc,
 cmpfunc, hashfunc, descrgetfunc, descrsetfunc, objobjproc, objobjargproc,
-getbufferproc, readbufferproc, ssizessizeobjargproc)
+getbufferproc, ssizessizeobjargproc)
 from pypy.module.cpyext.pyobject import from_ref, make_ref, Py_DecRef
 from pypy.module.cpyext.pyerrors import PyErr_Occurred
 from pypy.module.cpyext.state import State
@@ -22,6 +22,9 @@
 from rpython.rlib.objectmodel import specialize
 from rpython.tool.sourcetools import func_renamer
 from rpython.rtyper.annlowlevel import llhelper
+from pypy.module.sys.version import CPYTHON_VERSION
+
+PY3 = CPYTHON_VERSION[0] == 3
 
 # XXX: Also defined in object.h
 Py_LT = 0
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -14,7 +14,7 @@
 from pypy.module.cpyext import structmemberdefs
 from pypy.module.cpyext.api import (
 cpython_api, cpython_struct, bootstrap_function, Py_ssize_t, Py_ssize_tP,
-generic_cpy_call, Py_TPFLAGS_READY, Py_TPFLAGS_READYING,
+generic_cpy_call, Py_TPFLAGS_READY, Py_TPFLAGS_READYING, Py_buffer,
 Py_TPFLAGS_HEAPTYPE, METH_VARARGS, METH_KEYWORDS, CANNOT_FAIL,
 Py_TPFLAGS_HAVE_GETCHARBUFFER, build_type_checkers, StaticObjectBuilder,
 PyObjectFields, Py_TPFLAGS_BASETYPE, PyTypeObject, PyTypeObjectPtr,
diff --git a/pypy/module/cpyext/typeobjectdefs.py 
b/pypy/module/cpyext/typeobjectdefs.py
--- a/pypy/module/cpyext/typeobjectdefs.py
+++ b/pypy/module/cpyext/typeobjectdefs.py
@@ -1,7 +1,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rtyper.lltypesystem.lltype import Ptr, FuncType, Void
 from pypy.module.cpyext.api import (cpython_struct, Py_ssize_t, Py_ssize_tP,
-PyVarObjectFields, PyTypeObject, PyTypeObjectPtr, FILEP, Py_Buffer,
+PyVarObjectFields, PyTypeObject, PyTypeObjectPtr, FILEP, Py_buffer,
 Py_TPFLAGS_READYING, Py_TPFLAGS_READY, Py_TPFLAGS_HEAPTYPE)
 from pypy.module.cpyext.pyobject import PyObject, make_ref, from_ref
 from pypy.module.cpyext.modsupport import PyMethodDef
@@ -54,10 +54,6 @@
 wrapperfunc = P(FT([PyO, PyO, rffi.VOIDP], PyO))
 wrapperfunc_kwds = P(FT([PyO, PyO, rffi.VOIDP, PyO], PyO))
 
-readbufferproc = P(FT([PyO, Py_ssize_t, rffi.VOIDPP], Py_ssize_t))
-writebufferproc = P(FT([PyO, Py_ssize_t, rffi.VOIDPP], Py_ssize_t))
-segcountproc = P(FT([PyO, Py_ssize_tP], Py_ssize_t))
-charbufferproc = P(FT([PyO, Py_ssize_t, rffi.CCHARPP], Py_ssize_t))
 getbufferproc = P(FT([PyO, Py_bufferP, rffi.INT_real], rffi.INT_real))
 releasebufferproc = P(FT([PyO, Py_bufferP], Void))
 
@@ -131,10 +127,6 @@
 ))
 
 PyBufferProcs = cpython_struct("PyBufferProcs", (
-("bf_getreadbuffer", readbufferproc),
-("bf_getwritebuffer", writebufferproc),
-("bf_getsegcount", segcountproc),
-("bf_getcharbuffer", charbufferproc),
 ("bf_getbuffer", getbufferproc),
 ("bf_releasebuffer", releasebufferproc),
 ))
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -394,13 +394,6 @@
 of the specified width. The string S is never truncated.
 """
 
-def descr_hex(self, space):
-"""S.hex() -> string
-
-Creates a hexadecimal string of the bytes object
-"""
-
-
 class W_BytesObject(W_AbstractBytesObject):
 import_from_mixin(StringMethods)
 _immutable_fields_ = ['_value']
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -223,7 +223,7 @@
 pass
 
 if _WIN32:
-includes = ['io.h', 'sys/utime.h', 'sys/types.h', 'process.h']
+includes = ['io.h', 'sys/utime.h', 'sys/types.h', 'process.h', 'time.h']
 libraries = []
 else:
 if sys.platform.startswith(('darwin', 'netbsd', 'openbsd')):
@@ -254,10 +254,10 @@
 UTIMBUF = rffi_platform.Struct('struct %sutimbuf' % UNDERSCORE_ON_WIN32,
[('actime', rffi.INT),
 ('modtime', rffi.INT)])
+CLOCK_T = rffi_platform.SimpleType('clock_t', rffi.INT)
 if not _WIN32:
 UID_T = rffi_platform.SimpleType('uid_t', rffi.UINT)
 GID_T = rffi_platform.SimpleType('gid_t', rffi.UINT)
-CLOCK_T = rffi_platform.SimpleType('clock_t', rffi.INT)
 
 TMS = rffi_platform.Struct(
 'struct tms', [('tms_utime', rffi.INT),

[pypy-commit] pypy default: merge redirect-assembler-jitlog

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: 
Changeset: r86471:4b3bf21d99c6
Date: 2016-08-24 11:53 +0200
http://bitbucket.org/pypy/pypy/changeset/4b3bf21d99c6/

Log:merge redirect-assembler-jitlog

diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -1064,6 +1064,8 @@
 else:
 assert mc.get_relative_pos() <= 13
 mc.copy_to_raw_memory(oldadr)
+# log the redirection of the call_assembler_* operation
+jl.redirect_assembler(oldlooptoken, newlooptoken, target)
 
 def dump(self, text):
 if not self.verbose:
diff --git a/rpython/rlib/rjitlog/rjitlog.py b/rpython/rlib/rjitlog/rjitlog.py
--- a/rpython/rlib/rjitlog/rjitlog.py
+++ b/rpython/rlib/rjitlog/rjitlog.py
@@ -212,7 +212,7 @@
 return method
 return decor
 
-JITLOG_VERSION = 2
+JITLOG_VERSION = 3
 JITLOG_VERSION_16BIT_LE = struct.pack("

[pypy-commit] pypy py3k: import issue

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3k
Changeset: r86473:04a4bb69ff39
Date: 2016-08-24 11:12 +0200
http://bitbucket.org/pypy/pypy/changeset/04a4bb69ff39/

Log:import issue

diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -13,7 +13,6 @@
 WrappedDefault, interp2app, interpindirect2app, unwrap_spec)
 from pypy.interpreter.typedef import TypeDef
 from pypy.objspace.std import newformat
-from pypy.objspace.std.basestringtype import basestring_typedef
 from pypy.objspace.std.formatting import mod_format
 from pypy.objspace.std.stringmethods import StringMethods
 from pypy.objspace.std.unicodeobject import (
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: document branch

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: 
Changeset: r86472:dbdfb99f8932
Date: 2016-08-24 11:55 +0200
http://bitbucket.org/pypy/pypy/changeset/dbdfb99f8932/

Log:document branch

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
@@ -155,3 +155,7 @@
 
 Support for memoryview attributes (format, itemsize, ...).
 Extends the cpyext emulation layer.
+
+.. branch: redirect-assembler-jitlog
+
+Log more information to properly rebuild the redirected traces in jitviewer.
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: buffer protocal c headers are stripped down in py3

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3k
Changeset: r86474:d5bd69e6035c
Date: 2016-08-24 11:56 +0200
http://bitbucket.org/pypy/pypy/changeset/d5bd69e6035c/

Log:buffer protocal c headers are stripped down in py3

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
@@ -11,7 +11,7 @@
 getattrfunc, getattrofunc, setattrofunc, lenfunc, ssizeargfunc, inquiry,
 ssizessizeargfunc, ssizeobjargproc, iternextfunc, initproc, richcmpfunc,
 cmpfunc, hashfunc, descrgetfunc, descrsetfunc, objobjproc, objobjargproc,
-getbufferproc, readbufferproc, ssizessizeobjargproc)
+getbufferproc, ssizessizeobjargproc)
 from pypy.module.cpyext.pyobject import from_ref, make_ref, Py_DecRef
 from pypy.module.cpyext.pyerrors import PyErr_Occurred
 from pypy.module.cpyext.state import State
@@ -22,6 +22,9 @@
 from rpython.rlib.objectmodel import specialize
 from rpython.tool.sourcetools import func_renamer
 from rpython.rtyper.annlowlevel import llhelper
+from pypy.module.sys.version import CPYTHON_VERSION
+
+PY3 = CPYTHON_VERSION[0] == 3
 
 # XXX: Also defined in object.h
 Py_LT = 0
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -14,7 +14,7 @@
 from pypy.module.cpyext import structmemberdefs
 from pypy.module.cpyext.api import (
 cpython_api, cpython_struct, bootstrap_function, Py_ssize_t, Py_ssize_tP,
-generic_cpy_call, Py_TPFLAGS_READY, Py_TPFLAGS_READYING,
+generic_cpy_call, Py_TPFLAGS_READY, Py_TPFLAGS_READYING, Py_buffer,
 Py_TPFLAGS_HEAPTYPE, METH_VARARGS, METH_KEYWORDS, CANNOT_FAIL,
 Py_TPFLAGS_HAVE_GETCHARBUFFER, build_type_checkers, StaticObjectBuilder,
 PyObjectFields, Py_TPFLAGS_BASETYPE, PyTypeObject, PyTypeObjectPtr,
diff --git a/pypy/module/cpyext/typeobjectdefs.py 
b/pypy/module/cpyext/typeobjectdefs.py
--- a/pypy/module/cpyext/typeobjectdefs.py
+++ b/pypy/module/cpyext/typeobjectdefs.py
@@ -1,7 +1,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rtyper.lltypesystem.lltype import Ptr, FuncType, Void
 from pypy.module.cpyext.api import (cpython_struct, Py_ssize_t, Py_ssize_tP,
-PyVarObjectFields, PyTypeObject, PyTypeObjectPtr, FILEP, Py_Buffer,
+PyVarObjectFields, PyTypeObject, PyTypeObjectPtr, FILEP, Py_buffer,
 Py_TPFLAGS_READYING, Py_TPFLAGS_READY, Py_TPFLAGS_HEAPTYPE)
 from pypy.module.cpyext.pyobject import PyObject, make_ref, from_ref
 from pypy.module.cpyext.modsupport import PyMethodDef
@@ -54,10 +54,6 @@
 wrapperfunc = P(FT([PyO, PyO, rffi.VOIDP], PyO))
 wrapperfunc_kwds = P(FT([PyO, PyO, rffi.VOIDP, PyO], PyO))
 
-readbufferproc = P(FT([PyO, Py_ssize_t, rffi.VOIDPP], Py_ssize_t))
-writebufferproc = P(FT([PyO, Py_ssize_t, rffi.VOIDPP], Py_ssize_t))
-segcountproc = P(FT([PyO, Py_ssize_tP], Py_ssize_t))
-charbufferproc = P(FT([PyO, Py_ssize_t, rffi.CCHARPP], Py_ssize_t))
 getbufferproc = P(FT([PyO, Py_bufferP, rffi.INT_real], rffi.INT_real))
 releasebufferproc = P(FT([PyO, Py_bufferP], Void))
 
@@ -131,10 +127,6 @@
 ))
 
 PyBufferProcs = cpython_struct("PyBufferProcs", (
-("bf_getreadbuffer", readbufferproc),
-("bf_getwritebuffer", writebufferproc),
-("bf_getsegcount", segcountproc),
-("bf_getcharbuffer", charbufferproc),
 ("bf_getbuffer", getbufferproc),
 ("bf_releasebuffer", releasebufferproc),
 ))
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -15,9 +15,6 @@
 from pypy.objspace.std import newformat
 from pypy.objspace.std.formatting import mod_format
 from pypy.objspace.std.stringmethods import StringMethods
-from pypy.objspace.std.unicodeobject import (
-decode_object, unicode_from_encoded_object,
-unicode_from_string, getdefaultencoding)
 from pypy.objspace.std.util import IDTAG_SPECIAL, IDTAG_SHIFT
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the test (failed on OS/X 64 because x==y==sys.maxint typically)

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r86470:6bfe423a36a4
Date: 2016-08-24 11:51 +0200
http://bitbucket.org/pypy/pypy/changeset/6bfe423a36a4/

Log:Fix the test (failed on OS/X 64 because x==y==sys.maxint typically)

diff --git a/pypy/module/test_lib_pypy/test_resource.py 
b/pypy/module/test_lib_pypy/test_resource.py
--- a/pypy/module/test_lib_pypy/test_resource.py
+++ b/pypy/module/test_lib_pypy/test_resource.py
@@ -1,4 +1,5 @@
 from __future__ import absolute_import
+import sys
 
 import os
 if os.name != 'posix':
@@ -47,6 +48,9 @@
 # minimal "does not crash" test
 x, y = resource.getrlimit(resource.RLIMIT_CPU)
 resource.setrlimit(resource.RLIMIT_CPU, (x, y))
-x += 0.2
-y += 0.3
-resource.setrlimit(resource.RLIMIT_CPU, (x, y))# truncated to ints
+# sometimes, x and y are very large (more than 53 bits).
+# for these huge values, int(float(x)) > x...
+xf = x + 0.2
+yf = y + 0.3
+if int(xf) == x and int(yf) == y:
+resource.setrlimit(resource.RLIMIT_CPU, (x, y))  # truncated to ints
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: Merging with upstream 3k

2016-08-24 Thread marky1991
Author: Mark Young 
Branch: py3k
Changeset: r86468:159ee4a5dd97
Date: 2016-08-23 17:46 -0400
http://bitbucket.org/pypy/pypy/changeset/159ee4a5dd97/

Log:Merging with upstream 3k

diff too long, truncating to 2000 out of 35449 lines

diff --git a/dotviewer/graphparse.py b/dotviewer/graphparse.py
--- a/dotviewer/graphparse.py
+++ b/dotviewer/graphparse.py
@@ -85,10 +85,11 @@
 pass
 
 def splitline(line, re_word = re.compile(r'[^\s"]\S*|["]["]|["].*?[^\\]["]')):
+import ast
 result = []
 for word in re_word.findall(line):
 if word.startswith('"'):
-word = eval(word)
+word = ast.literal_eval(word)
 result.append(word)
 return result
 
diff --git a/include/PyPy.h b/include/PyPy.h
--- a/include/PyPy.h
+++ b/include/PyPy.h
@@ -2,7 +2,11 @@
 #define _PYPY_H_
 
 /* This header is meant to be included in programs that use PyPy as an
-   embedded library. */
+   embedded library.
+
+   NOTE: this is deprecated.  Instead, use cffi's embedding support:
+   http://cffi.readthedocs.org/en/latest/embedding.html
+*/
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/lib-python/2.7/test/test_hash.py b/lib-python/2.7/test/test_hash.py
--- a/lib-python/2.7/test/test_hash.py
+++ b/lib-python/2.7/test/test_hash.py
@@ -174,7 +174,7 @@
 
 class StringlikeHashRandomizationTests(HashRandomizationTests):
 if check_impl_detail(pypy=True):
-EMPTY_STRING_HASH = -1
+EMPTY_STRING_HASH = -2
 else:
 EMPTY_STRING_HASH = 0
 
diff --git a/lib-python/3/test/test_compileall.py 
b/lib-python/3/test/test_compileall.py
--- a/lib-python/3/test/test_compileall.py
+++ b/lib-python/3/test/test_compileall.py
@@ -202,11 +202,10 @@
 
 # Ensure that the default behavior of compileall's CLI is to create
 # PEP 3147 pyc/pyo files.
-_pyo = 'pyo' if support.check_impl_detail() else 'pyc'
 for name, ext, switch in [
 ('normal', 'pyc', []),
-('optimize', _pyo, ['-O']),
-('doubleoptimize', _pyo, ['-OO']),
+('optimize', 'pyo', ['-O']),
+('doubleoptimize', 'pyo', ['-OO']),
 ]:
 def f(self, ext=ext, switch=switch):
 script_helper.assert_python_ok(*(switch +
diff --git a/lib-python/3/test/test_hash.py b/lib-python/3/test/test_hash.py
--- a/lib-python/3/test/test_hash.py
+++ b/lib-python/3/test/test_hash.py
@@ -164,7 +164,7 @@
 
 class StringlikeHashRandomizationTests(HashRandomizationTests):
 if check_impl_detail(pypy=True):
-EMPTY_STRING_HASH = -1
+EMPTY_STRING_HASH = -2
 else:
 EMPTY_STRING_HASH = 0
 
diff --git a/lib-python/3/test/test_unicode.py 
b/lib-python/3/test/test_unicode.py
--- a/lib-python/3/test/test_unicode.py
+++ b/lib-python/3/test/test_unicode.py
@@ -2199,7 +2199,8 @@
 def test_getnewargs(self):
 text = 'abc'
 args = text.__getnewargs__()
-self.assertIsNot(args[0], text)
+if support.check_impl_detail():
+self.assertIsNot(args[0], text)
 self.assertEqual(args[0], text)
 self.assertEqual(len(args), 1)
 
diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -198,10 +198,13 @@
 return tp._alignmentofinstances()
 
 @builtinify
-def byref(cdata):
+def byref(cdata, offset=0):
 # "pointer" is imported at the end of this module to avoid circular
 # imports
-return pointer(cdata)
+ptr = pointer(cdata)
+if offset != 0:
+ptr._buffer[0] += offset
+return ptr
 
 def cdata_from_address(self, address):
 # fix the address: turn it into as unsigned, in case it's a negative number
diff --git a/lib_pypy/_pypy_winbase_build.py b/lib_pypy/_pypy_winbase_build.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/_pypy_winbase_build.py
@@ -0,0 +1,91 @@
+# Note: uses the CFFI out-of-line ABI mode.  We can't use the API
+# mode because ffi.compile() needs to run the compiler, which
+# needs 'subprocess', which needs 'msvcrt' and '_subprocess',
+# which depend on '_pypy_winbase_cffi' already.
+#
+# Note that if you need to regenerate _pypy_winbase_cffi and
+# can't use a preexisting PyPy to do that, then running this
+# file should work as long as 'subprocess' is not imported
+# by cffi.  I had to hack in 'cffi._pycparser' to move an
+#'import subprocess' to the inside of a function.  (Also,
+# CPython+CFFI should work as well.)
+#
+# This module supports both msvcrt.py and _subprocess.py.
+
+from cffi import FFI
+
+ffi = FFI()
+
+ffi.set_source("_pypy_winbase_cffi", None)
+
+# -- MSVCRT --
+
+ffi.cdef("""
+typedef unsigned short wint_t;
+
+int _open_osfhandle(intptr_t osfhandle, int flags);
+intptr_t _get_osfhandle(int fd);
+int _setmode(int fd, int mode);
+int _locking(int fd, int mode, long nbytes);
+
+int _kbhit(void);
+int _getch(void);
+wint_t _getwch(void);
+int _getche(void);
+wint_t _getwche(void);
+int _putch(int);
+wint_t _putwch(wchar_t);

[pypy-commit] pypy py3k: Merging from windows with linux side

2016-08-24 Thread marky1991
Author: Mark Young 
Branch: py3k
Changeset: r86467:c78024f7ecad
Date: 2016-08-23 17:40 -0400
http://bitbucket.org/pypy/pypy/changeset/c78024f7ecad/

Log:Merging from windows with linux side

diff too long, truncating to 2000 out of 5058 lines

diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -452,7 +452,7 @@
 RegrTest('test_userstring.py', core=True),
 RegrTest('test_uu.py'),
 RegrTest('test_uuid.py'),
-RegrTest('test_venv.py'),
+RegrTest('test_venv.py', usemodules="struct"),
 RegrTest('test_wait3.py', usemodules="thread"),
 RegrTest('test_wait4.py', usemodules="thread"),
 RegrTest('test_warnings.py', core=True),
diff --git a/pypy/module/_posixsubprocess/interp_subprocess.py 
b/pypy/module/_posixsubprocess/interp_subprocess.py
--- a/pypy/module/_posixsubprocess/interp_subprocess.py
+++ b/pypy/module/_posixsubprocess/interp_subprocess.py
@@ -15,8 +15,9 @@
 
 class CConfig:
 _compilation_info_ = ExternalCompilationInfo(
-includes=['unistd.h', 'sys/syscall.h'])
+includes=['unistd.h', 'sys/syscall.h', 'sys/stat.h'])
 HAVE_SYS_SYSCALL_H = platform.Has("syscall")
+HAVE_SYS_STAT_H = platform.Has("stat")
 HAVE_SETSID = platform.Has("setsid")
 
 config = platform.configure(CConfig)
@@ -29,6 +30,8 @@
 compile_extra = []
 if config['HAVE_SYS_SYSCALL_H']:
 compile_extra.append("-DHAVE_SYS_SYSCALL_H")
+if config['HAVE_SYS_STAT_H']:
+compile_extra.append("-DHAVE_SYS_STAT_H")
 if config['HAVE_SETSID']:
 compile_extra.append("-DHAVE_SETSID")
 
diff --git a/pypy/module/time/interp_time.py b/pypy/module/time/interp_time.py
--- a/pypy/module/time/interp_time.py
+++ b/pypy/module/time/interp_time.py
@@ -159,7 +159,6 @@
 libraries=rtime.libraries
 )
 CLOCKS_PER_SEC = platform.ConstantInteger("CLOCKS_PER_SEC")
-clock_t = platform.SimpleType("clock_t", rffi.ULONG)
 has_gettimeofday = platform.Has('gettimeofday')
 has_clock_gettime = platform.Has('clock_gettime')
 CLOCK_PROF = platform.DefinedConstantInteger('CLOCK_PROF')
@@ -233,7 +232,6 @@
 HAS_CLOCK_MONOTONIC = cConfig.CLOCK_MONOTONIC is not None
 HAS_MONOTONIC = (_WIN or _MACOSX or
  (HAS_CLOCK_GETTIME and (HAS_CLOCK_HIGHRES or 
HAS_CLOCK_MONOTONIC)))
-clock_t = cConfig.clock_t
 tm = cConfig.tm
 glob_buf = lltype.malloc(tm, flavor='raw', zero=True, immortal=True)
 
@@ -1024,7 +1022,10 @@
 with lltype.scoped_alloc(rposix.TMS) as tms:
 ret = rposix.c_times(tms)
 if rffi.cast(lltype.Signed, ret) != -1:
-cpu_time = float(tms.c_tms_utime + tms.c_tms_stime)
+cpu_time = float(rffi.cast(lltype.Signed,
+   tms.c_tms_utime) +
+ rffi.cast(lltype.Signed,
+   tms.c_tms_stime))
 if w_info is not None:
 _setinfo(space, w_info, "times()",
  1.0 / rposix.CLOCK_TICKS_PER_SECOND,
@@ -1032,7 +1033,7 @@
 return space.wrap(cpu_time / rposix.CLOCK_TICKS_PER_SECOND)
 return clock(space)
 
-_clock = external('clock', [], clock_t)
+_clock = external('clock', [], rposix.CLOCK_T)
 def clock(space, w_info=None):
 """clock() -> floating point number
 
@@ -1046,7 +1047,7 @@
 pass
 value = _clock()
 # Is this casting correct?
-if value == rffi.cast(clock_t, -1):
+if intmask(value) == intmask(rffi.cast(rposix.CLOCK_T, -1)):
 raise oefmt(space.w_RuntimeError,
 "the processor time used is not available or its value"
 "cannot be represented")
diff --git a/pypy/objspace/std/test/test_obj.py 
b/pypy/objspace/std/test/test_obj.py
--- a/pypy/objspace/std/test/test_obj.py
+++ b/pypy/objspace/std/test/test_obj.py
@@ -211,11 +211,10 @@
 
 def test_identity_vs_id_primitives(self):
 import sys
-l = range(-10, 10, 2)
+l = list(range(-10, 10, 2))
 for i in [0, 1, 3]:
 l.append(float(i))
 l.append(i + 0.1)
-l.append(long(i))
 l.append(i + sys.maxsize)
 l.append(i - sys.maxsize)
 l.append(i + 1j)
diff --git a/pypy/objspace/std/test/test_unicodeobject.py 
b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -976,3 +976,12 @@
 raises(TypeError, "u''.encode(None)")
 raises(TypeError, "str(b'', encoding=None)")
 raises(TypeError, 'u"".encode("utf-8", None)')
+
+def test_casefold(self):
+assert 'hello'.casefold() == 'hello'
+assert 'hELlo'.casefold() == 'hello'
+assert ''.casefold() == 'ss'
+assert ''.casefold() == 'fi'
+assert '\u03a3'.casefold() == 

[pypy-commit] pypy py3k: Merged in marky1991/pypy_new/py3k (pull request #474)

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: py3k
Changeset: r86469:213acc3c585e
Date: 2016-08-24 11:40 +0200
http://bitbucket.org/pypy/pypy/changeset/213acc3c585e/

Log:Merged in marky1991/pypy_new/py3k (pull request #474)

Define clock_t on windows (py3k)

diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -223,7 +223,7 @@
 pass
 
 if _WIN32:
-includes = ['io.h', 'sys/utime.h', 'sys/types.h', 'process.h']
+includes = ['io.h', 'sys/utime.h', 'sys/types.h', 'process.h', 'time.h']
 libraries = []
 else:
 if sys.platform.startswith(('darwin', 'netbsd', 'openbsd')):
@@ -254,10 +254,10 @@
 UTIMBUF = rffi_platform.Struct('struct %sutimbuf' % UNDERSCORE_ON_WIN32,
[('actime', rffi.INT),
 ('modtime', rffi.INT)])
+CLOCK_T = rffi_platform.SimpleType('clock_t', rffi.INT)
 if not _WIN32:
 UID_T = rffi_platform.SimpleType('uid_t', rffi.UINT)
 GID_T = rffi_platform.SimpleType('gid_t', rffi.UINT)
-CLOCK_T = rffi_platform.SimpleType('clock_t', rffi.INT)
 
 TMS = rffi_platform.Struct(
 'struct tms', [('tms_utime', rffi.INT),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: Define clock_t on windows too.

2016-08-24 Thread marky1991
Author: Mark Young 
Branch: py3k
Changeset: r86466:9f32d69d4211
Date: 2016-08-23 17:38 -0400
http://bitbucket.org/pypy/pypy/changeset/9f32d69d4211/

Log:Define clock_t on windows too.

diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -220,7 +220,8 @@
 pass
 
 if _WIN32:
-includes = ['io.h', 'sys/utime.h', 'sys/types.h']
+includes = ['io.h', 'sys/utime.h', 'sys/types.h',
+'time.h']
 libraries = []
 else:
 if sys.platform.startswith(('darwin', 'netbsd', 'openbsd')):
@@ -250,9 +251,8 @@
 UTIMBUF = rffi_platform.Struct('struct %sutimbuf' % UNDERSCORE_ON_WIN32,
[('actime', rffi.INT),
 ('modtime', rffi.INT)])
+CLOCK_T = rffi_platform.SimpleType('clock_t', rffi.INT)
 if not _WIN32:
-CLOCK_T = rffi_platform.SimpleType('clock_t', rffi.INT)
-
 TMS = rffi_platform.Struct(
 'struct tms', [('tms_utime', rffi.INT),
('tms_stime', rffi.INT),
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Update the comments about the reason for duplicating these few lines of

2016-08-24 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r86465:7f8f51b42ad0
Date: 2016-08-24 11:36 +0200
http://bitbucket.org/pypy/pypy/changeset/7f8f51b42ad0/

Log:Update the comments about the reason for duplicating these few lines
of code from lib-python/3/code.py.

diff --git a/lib_pypy/_pypy_interact.py b/lib_pypy/_pypy_interact.py
--- a/lib_pypy/_pypy_interact.py
+++ b/lib_pypy/_pypy_interact.py
@@ -49,9 +49,11 @@
 if mainmodule is None:
 import __main__ as mainmodule
 console = code.InteractiveConsole(mainmodule.__dict__, filename='')
-# some parts of code.py are copied here because it seems to be impossible
+# some parts of code.py are copied here because it was impossible
 # to start an interactive console without printing at least one line
-# of banner
+# of banner.  This was fixed in 3.4; but then from 3.6 it prints a
+# line when exiting.  This can be disabled too---by passing an argument
+# that doesn't exist in <= 3.5.  So, too much mess: just copy the code.
 more = 0
 while 1:
 try:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: pull some merge conflicts from py3k

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r86462:74d03f9c65e8
Date: 2016-08-24 10:34 +0200
http://bitbucket.org/pypy/pypy/changeset/74d03f9c65e8/

Log:pull some merge conflicts from py3k

diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -208,7 +208,7 @@
 
 def cdata_from_address(self, address):
 # fix the address: turn it into as unsigned, in case it's a negative number
-address = address & (sys.maxint * 2 + 1)
+address = address & (sys.maxsize * 2 + 1)
 instance = self.__new__(self)
 lgt = getattr(self, '_length_', 1)
 instance._buffer = self._ffiarray.fromaddress(address, lgt)
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -585,11 +585,6 @@
 self.sys = Module(self, w_name)
 self.sys.install()
 
-from pypy.module.imp import Module
-w_name = self.wrap('imp')
-mod = Module(self, w_name)
-mod.install()
-
 from pypy.module.__builtin__ import Module
 w_name = self.wrap('builtins')
 self.builtin = Module(self, w_name)
@@ -2001,7 +1996,7 @@
 
 ObjSpace.IrregularOpTable = [
 'wrap',
-'str_w',
+'bytes_w',
 'int_w',
 'float_w',
 'uint_w',
diff --git a/pypy/module/cpyext/typeobjectdefs.py 
b/pypy/module/cpyext/typeobjectdefs.py
--- a/pypy/module/cpyext/typeobjectdefs.py
+++ b/pypy/module/cpyext/typeobjectdefs.py
@@ -1,7 +1,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rtyper.lltypesystem.lltype import Ptr, FuncType, Void
 from pypy.module.cpyext.api import (cpython_struct, Py_ssize_t, Py_ssize_tP,
-PyVarObjectFields, PyTypeObject, PyTypeObjectPtr, FILEP,
+PyVarObjectFields, PyTypeObject, PyTypeObjectPtr, FILEP, Py_Buffer,
 Py_TPFLAGS_READYING, Py_TPFLAGS_READY, Py_TPFLAGS_HEAPTYPE)
 from pypy.module.cpyext.pyobject import PyObject, make_ref, from_ref
 from pypy.module.cpyext.modsupport import PyMethodDef
@@ -59,7 +59,7 @@
 segcountproc = P(FT([PyO, Py_ssize_tP], Py_ssize_t))
 charbufferproc = P(FT([PyO, Py_ssize_t, rffi.CCHARPP], Py_ssize_t))
 getbufferproc = P(FT([PyO, Py_bufferP, rffi.INT_real], rffi.INT_real))
-releasebufferproc = P(FT([PyO, Ptr(Py_buffer)], Void))
+releasebufferproc = P(FT([PyO, Py_bufferP], Void))
 
 
 PyGetSetDef = cpython_struct("PyGetSetDef", (
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: resolve some merge conflicts

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3k
Changeset: r86461:7011e843b4a7
Date: 2016-08-24 10:34 +0200
http://bitbucket.org/pypy/pypy/changeset/7011e843b4a7/

Log:resolve some merge conflicts

diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -208,7 +208,7 @@
 
 def cdata_from_address(self, address):
 # fix the address: turn it into as unsigned, in case it's a negative number
-address = address & (sys.maxint * 2 + 1)
+address = address & (sys.maxsize * 2 + 1)
 instance = self.__new__(self)
 lgt = getattr(self, '_length_', 1)
 instance._buffer = self._ffiarray.fromaddress(address, lgt)
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -585,11 +585,6 @@
 self.sys = Module(self, w_name)
 self.sys.install()
 
-from pypy.module.imp import Module
-w_name = self.wrap('imp')
-mod = Module(self, w_name)
-mod.install()
-
 from pypy.module.__builtin__ import Module
 w_name = self.wrap('builtins')
 self.builtin = Module(self, w_name)
@@ -1998,7 +1993,7 @@
 
 ObjSpace.IrregularOpTable = [
 'wrap',
-'str_w',
+'bytes_w',
 'int_w',
 'float_w',
 'uint_w',
diff --git a/pypy/module/cpyext/typeobjectdefs.py 
b/pypy/module/cpyext/typeobjectdefs.py
--- a/pypy/module/cpyext/typeobjectdefs.py
+++ b/pypy/module/cpyext/typeobjectdefs.py
@@ -1,7 +1,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rtyper.lltypesystem.lltype import Ptr, FuncType, Void
 from pypy.module.cpyext.api import (cpython_struct, Py_ssize_t, Py_ssize_tP,
-PyVarObjectFields, PyTypeObject, PyTypeObjectPtr, FILEP,
+PyVarObjectFields, PyTypeObject, PyTypeObjectPtr, FILEP, Py_Buffer,
 Py_TPFLAGS_READYING, Py_TPFLAGS_READY, Py_TPFLAGS_HEAPTYPE)
 from pypy.module.cpyext.pyobject import PyObject, make_ref, from_ref
 from pypy.module.cpyext.modsupport import PyMethodDef
@@ -59,7 +59,7 @@
 segcountproc = P(FT([PyO, Py_ssize_tP], Py_ssize_t))
 charbufferproc = P(FT([PyO, Py_ssize_t, rffi.CCHARPP], Py_ssize_t))
 getbufferproc = P(FT([PyO, Py_bufferP, rffi.INT_real], rffi.INT_real))
-releasebufferproc = P(FT([PyO, Ptr(Py_buffer)], Void))
+releasebufferproc = P(FT([PyO, Py_bufferP], Void))
 
 
 PyGetSetDef = cpython_struct("PyGetSetDef", (
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: cpyext, struct to usemodules

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r86463:f8a9272bbf66
Date: 2016-08-24 11:00 +0200
http://bitbucket.org/pypy/pypy/changeset/f8a9272bbf66/

Log:cpyext, struct to usemodules

diff --git a/pypy/module/_cffi_backend/test/test_recompiler.py 
b/pypy/module/_cffi_backend/test/test_recompiler.py
--- a/pypy/module/_cffi_backend/test/test_recompiler.py
+++ b/pypy/module/_cffi_backend/test/test_recompiler.py
@@ -79,7 +79,7 @@
 
 
 class AppTestRecompiler:
-spaceconfig = dict(usemodules=['_cffi_backend', 'imp'])
+spaceconfig = dict(usemodules=['_cffi_backend', 'imp', 'cpyext', 'struct'])
 
 def setup_class(cls):
 if cls.runappdirect:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge py3k

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r86460:304a36465049
Date: 2016-08-24 10:29 +0200
http://bitbucket.org/pypy/pypy/changeset/304a36465049/

Log:merge py3k

diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -166,8 +166,8 @@
 else:
 return self.value
 
-def __buffer__(self):
-return memoryview(self._buffer)
+def __buffer__(self, flags):
+return buffer(self._buffer)
 
 def _get_b_base(self):
 try:
@@ -208,7 +208,7 @@
 
 def cdata_from_address(self, address):
 # fix the address: turn it into as unsigned, in case it's a negative number
-address = address & (sys.maxsize * 2 + 1)
+address = address & (sys.maxint * 2 + 1)
 instance = self.__new__(self)
 lgt = getattr(self, '_length_', 1)
 instance._buffer = self._ffiarray.fromaddress(address, lgt)
diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py
--- a/lib_pypy/cffi/recompiler.py
+++ b/lib_pypy/cffi/recompiler.py
@@ -515,7 +515,7 @@
 tovar, errcode)
 return
 #
-elif isinstance(tp, (model.StructOrUnion, model.EnumType)):
+elif isinstance(tp, model.StructOrUnionOrEnum):
 # a struct (not a struct pointer) as a function argument
 self._prnt('  if (_cffi_to_c((char *)&%s, _cffi_type(%d), %s) < 0)'
   % (tovar, self._gettypenum(tp), fromvar))
@@ -572,7 +572,7 @@
 elif isinstance(tp, model.ArrayType):
 return '_cffi_from_c_pointer((char *)%s, _cffi_type(%d))' % (
 var, self._gettypenum(model.PointerType(tp.item)))
-elif isinstance(tp, model.StructType):
+elif isinstance(tp, model.StructOrUnion):
 if tp.fldnames is None:
 raise TypeError("'%s' is used as %s, but is opaque" % (
 tp._get_c_name(), context))
diff --git a/lib_pypy/cffi/vengine_cpy.py b/lib_pypy/cffi/vengine_cpy.py
--- a/lib_pypy/cffi/vengine_cpy.py
+++ b/lib_pypy/cffi/vengine_cpy.py
@@ -308,7 +308,7 @@
 elif isinstance(tp, model.ArrayType):
 return '_cffi_from_c_pointer((char *)%s, _cffi_type(%d))' % (
 var, self._gettypenum(model.PointerType(tp.item)))
-elif isinstance(tp, model.StructType):
+elif isinstance(tp, model.StructOrUnion):
 if tp.fldnames is None:
 raise TypeError("'%s' is used as %s, but is opaque" % (
 tp._get_c_name(), context))
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
@@ -144,3 +144,14 @@
 ``type.__dict__`` now returns a ``dict_proxy`` object, like on CPython.
 Previously it returned what looked like a regular dict object (but it
 was already read-only).
+
+
+.. branch: const-fold-we-are-jitted
+
+Reduce the size of the generated C code by constant-folding ``we_are_jitted``
+in non-jitcode.
+
+.. branch: memoryview-attributes
+
+Support for memoryview attributes (format, itemsize, ...).
+Extends the cpyext emulation layer.
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -585,6 +585,11 @@
 self.sys = Module(self, w_name)
 self.sys.install()
 
+from pypy.module.imp import Module
+w_name = self.wrap('imp')
+mod = Module(self, w_name)
+mod.install()
+
 from pypy.module.__builtin__ import Module
 w_name = self.wrap('builtins')
 self.builtin = Module(self, w_name)
@@ -1996,7 +2001,7 @@
 
 ObjSpace.IrregularOpTable = [
 'wrap',
-'bytes_w',
+'str_w',
 'int_w',
 'float_w',
 'uint_w',
diff --git a/pypy/module/_cffi_backend/test/test_recompiler.py 
b/pypy/module/_cffi_backend/test/test_recompiler.py
--- a/pypy/module/_cffi_backend/test/test_recompiler.py
+++ b/pypy/module/_cffi_backend/test/test_recompiler.py
@@ -79,7 +79,7 @@
 
 
 class AppTestRecompiler:
-spaceconfig = dict(usemodules=['_cffi_backend', 'imp', 'cpyext', 'struct'])
+spaceconfig = dict(usemodules=['_cffi_backend', 'imp'])
 
 def setup_class(cls):
 if cls.runappdirect:
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -120,7 +120,7 @@
 Py_TPFLAGS_READY Py_TPFLAGS_READYING Py_TPFLAGS_HAVE_GETCHARBUFFER
 METH_COEXIST METH_STATIC METH_CLASS Py_TPFLAGS_BASETYPE
 METH_NOARGS METH_VARARGS METH_KEYWORDS METH_O
-Py_TPFLAGS_HEAPTYPE Py_TPFLAGS_HAVE_CLASS
+Py_TPFLAGS_HEAPTYPE Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_HAVE_NEWBUFFER
 Py_LT Py_LE Py_EQ Py_NE Py_GT Py_GE Py_TPFLAGS_CHECKTYPES
 Py_CLEANUP_SUPPORTED
 """.split()
@@ -651,6 +651,7 @@
 #('smalltable', rffi.CFixedArray(Py_ssize_t, 2)),
 

[pypy-commit] pypy py3k: merge default

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: py3k
Changeset: r86459:281ace7115cb
Date: 2016-08-24 09:59 +0200
http://bitbucket.org/pypy/pypy/changeset/281ace7115cb/

Log:merge default

diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -166,8 +166,8 @@
 else:
 return self.value
 
-def __buffer__(self):
-return memoryview(self._buffer)
+def __buffer__(self, flags):
+return buffer(self._buffer)
 
 def _get_b_base(self):
 try:
@@ -208,7 +208,7 @@
 
 def cdata_from_address(self, address):
 # fix the address: turn it into as unsigned, in case it's a negative number
-address = address & (sys.maxsize * 2 + 1)
+address = address & (sys.maxint * 2 + 1)
 instance = self.__new__(self)
 lgt = getattr(self, '_length_', 1)
 instance._buffer = self._ffiarray.fromaddress(address, lgt)
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
@@ -150,3 +150,8 @@
 
 Reduce the size of the generated C code by constant-folding ``we_are_jitted``
 in non-jitcode.
+
+.. branch: memoryview-attributes
+
+Support for memoryview attributes (format, itemsize, ...).
+Extends the cpyext emulation layer.
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -585,6 +585,11 @@
 self.sys = Module(self, w_name)
 self.sys.install()
 
+from pypy.module.imp import Module
+w_name = self.wrap('imp')
+mod = Module(self, w_name)
+mod.install()
+
 from pypy.module.__builtin__ import Module
 w_name = self.wrap('builtins')
 self.builtin = Module(self, w_name)
@@ -1993,7 +1998,7 @@
 
 ObjSpace.IrregularOpTable = [
 'wrap',
-'bytes_w',
+'str_w',
 'int_w',
 'float_w',
 'uint_w',
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -120,7 +120,7 @@
 Py_TPFLAGS_READY Py_TPFLAGS_READYING Py_TPFLAGS_HAVE_GETCHARBUFFER
 METH_COEXIST METH_STATIC METH_CLASS Py_TPFLAGS_BASETYPE
 METH_NOARGS METH_VARARGS METH_KEYWORDS METH_O
-Py_TPFLAGS_HEAPTYPE Py_TPFLAGS_HAVE_CLASS
+Py_TPFLAGS_HEAPTYPE Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_HAVE_NEWBUFFER
 Py_LT Py_LE Py_EQ Py_NE Py_GT Py_GE Py_TPFLAGS_CHECKTYPES
 Py_CLEANUP_SUPPORTED
 """.split()
@@ -651,6 +651,7 @@
 #('smalltable', rffi.CFixedArray(Py_ssize_t, 2)),
 ('internal', rffi.VOIDP)
 ))
+Py_bufferP = lltype.Ptr(Py_buffer)
 
 @specialize.memo()
 def is_PyObject(TYPE):
diff --git a/pypy/module/cpyext/buffer.py b/pypy/module/cpyext/buffer.py
--- a/pypy/module/cpyext/buffer.py
+++ b/pypy/module/cpyext/buffer.py
@@ -1,8 +1,37 @@
+from pypy.interpreter.error import oefmt
 from rpython.rtyper.lltypesystem import rffi, lltype
 from rpython.rlib import buffer
 from pypy.module.cpyext.api import (
 cpython_api, CANNOT_FAIL, Py_buffer)
-from pypy.module.cpyext.pyobject import PyObject, Py_DecRef
+from pypy.module.cpyext.pyobject import PyObject
+
+@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
+def PyObject_CheckBuffer(space, w_obj):
+"""Return 1 if obj supports the buffer interface otherwise 0."""
+return 0  # the bf_getbuffer field is never filled by cpyext
+
+@cpython_api([PyObject, lltype.Ptr(Py_buffer), rffi.INT_real],
+ rffi.INT_real, error=-1)
+def PyObject_GetBuffer(space, w_obj, view, flags):
+"""Export obj into a Py_buffer, view.  These arguments must
+never be NULL.  The flags argument is a bit field indicating what
+kind of buffer the caller is prepared to deal with and therefore what
+kind of buffer the exporter is allowed to return.  The buffer interface
+allows for complicated memory sharing possibilities, but some caller may
+not be able to handle all the complexity but may want to see if the
+exporter will let them take a simpler view to its memory.
+
+Some exporters may not be able to share memory in every possible way and
+may need to raise errors to signal to some consumers that something is
+just not possible. These errors should be a BufferError unless
+there is another error that is actually causing the problem. The
+exporter can use flags information to simplify how much of the
+Py_buffer structure is filled in with non-default values and/or
+raise an error if the object can't support a simpler view of its memory.
+
+0 is returned on success and -1 on error."""
+raise oefmt(space.w_TypeError,
+"PyPy does not yet implement the new buffer interface")
 
 @cpython_api([lltype.Ptr(Py_buffer), lltype.Char], rffi.INT_real, 
error=CANNOT_FAIL)
 def PyBuffer_IsContiguous(space, view, fortran):
diff --git a/pypy/module/cpyext/memoryobject.py 

[pypy-commit] pypy memoryview-attributes: merge default

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: memoryview-attributes
Changeset: r86455:4ec423c97a35
Date: 2016-08-24 09:10 +0200
http://bitbucket.org/pypy/pypy/changeset/4ec423c97a35/

Log:merge default

diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py
--- a/lib_pypy/cffi/recompiler.py
+++ b/lib_pypy/cffi/recompiler.py
@@ -515,7 +515,7 @@
 tovar, errcode)
 return
 #
-elif isinstance(tp, (model.StructOrUnion, model.EnumType)):
+elif isinstance(tp, model.StructOrUnionOrEnum):
 # a struct (not a struct pointer) as a function argument
 self._prnt('  if (_cffi_to_c((char *)&%s, _cffi_type(%d), %s) < 0)'
   % (tovar, self._gettypenum(tp), fromvar))
@@ -572,7 +572,7 @@
 elif isinstance(tp, model.ArrayType):
 return '_cffi_from_c_pointer((char *)%s, _cffi_type(%d))' % (
 var, self._gettypenum(model.PointerType(tp.item)))
-elif isinstance(tp, model.StructType):
+elif isinstance(tp, model.StructOrUnion):
 if tp.fldnames is None:
 raise TypeError("'%s' is used as %s, but is opaque" % (
 tp._get_c_name(), context))
diff --git a/lib_pypy/cffi/vengine_cpy.py b/lib_pypy/cffi/vengine_cpy.py
--- a/lib_pypy/cffi/vengine_cpy.py
+++ b/lib_pypy/cffi/vengine_cpy.py
@@ -308,7 +308,7 @@
 elif isinstance(tp, model.ArrayType):
 return '_cffi_from_c_pointer((char *)%s, _cffi_type(%d))' % (
 var, self._gettypenum(model.PointerType(tp.item)))
-elif isinstance(tp, model.StructType):
+elif isinstance(tp, model.StructOrUnion):
 if tp.fldnames is None:
 raise TypeError("'%s' is used as %s, but is opaque" % (
 tp._get_c_name(), context))
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
@@ -144,3 +144,9 @@
 ``type.__dict__`` now returns a ``dict_proxy`` object, like on CPython.
 Previously it returned what looked like a regular dict object (but it
 was already read-only).
+
+
+.. branch: const-fold-we-are-jitted
+
+Reduce the size of the generated C code by constant-folding ``we_are_jitted``
+in non-jitcode.
diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -590,6 +590,8 @@
 "decode", w_fs_encoding)
 except OperationError as e:
 # fall back to the original byte string
+if e.async(space):
+raise
 result_w[i] = w_bytes
 return space.newlist(result_w)
 else:
diff --git a/pypy/module/pypyjit/test_pypy_c/test_ffi.py 
b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
--- a/pypy/module/pypyjit/test_pypy_c/test_ffi.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_ffi.py
@@ -423,7 +423,7 @@
 guard_false(i114, descr=...)
 --TICK--
 i123 = arraylen_gc(p67, descr=)
-i119 = call_i(ConstClass(_ll_1_raw_malloc_varsize__Signed), 6, 
descr=)
+i119 = call_i(ConstClass(_ll_1_raw_malloc_varsize_zero__Signed), 6, 
descr=)
 check_memory_error(i119)
 raw_store(i119, 0, i160, descr=)
 raw_store(i119, 2, i160, descr=)
diff --git a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py 
b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
--- a/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/cffi1/test_recompiler.py
@@ -1963,3 +1963,21 @@
ffi, "test_function_returns_opaque", "?")
 assert str(e.value) == ("function foo: 'struct a' is used as result type,"
 " but is opaque")
+
+def test_function_returns_union():
+ffi = FFI()
+ffi.cdef("union u1 { int a, b; }; union u1 f1(int);")
+lib = verify(ffi, "test_function_returns_union", """
+union u1 { int a, b; };
+static union u1 f1(int x) { union u1 u; u.b = x; return u; }
+""")
+assert lib.f1(51).a == 51
+
+def test_function_returns_partial_struct():
+ffi = FFI()
+ffi.cdef("struct a { int a; ...; }; struct a f1(int);")
+lib = verify(ffi, "test_function_returns_partial_struct", """
+struct a { int b, a, c; };
+static struct a f1(int x) { struct a s = {0}; s.a = x; return s; }
+""")
+assert lib.f1(52).a == 52
diff --git a/pypy/objspace/std/bytesobject.py b/pypy/objspace/std/bytesobject.py
--- a/pypy/objspace/std/bytesobject.py
+++ b/pypy/objspace/std/bytesobject.py
@@ -466,8 +466,6 @@
 def descr_getbuffer(self, space, w_flags):
 #from pypy.objspace.std.bufferobject import W_Buffer
 #return 

[pypy-commit] pypy memoryview-attributes: close branch

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: memoryview-attributes
Changeset: r86458:9ac7d2defab0
Date: 2016-08-24 09:13 +0200
http://bitbucket.org/pypy/pypy/changeset/9ac7d2defab0/

Log:close branch

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge memoryview-attributes

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: 
Changeset: r86456:0d29b975452d
Date: 2016-08-24 09:10 +0200
http://bitbucket.org/pypy/pypy/changeset/0d29b975452d/

Log:merge memoryview-attributes

diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py
--- a/lib_pypy/_ctypes/basics.py
+++ b/lib_pypy/_ctypes/basics.py
@@ -167,7 +167,7 @@
 else:
 return self.value
 
-def __buffer__(self):
+def __buffer__(self, flags):
 return buffer(self._buffer)
 
 def _get_b_base(self):
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -208,7 +208,8 @@
 def buffer_w(self, space, flags):
 w_impl = space.lookup(self, '__buffer__')
 if w_impl is not None:
-w_result = space.get_and_call_function(w_impl, self)
+w_result = space.get_and_call_function(w_impl, self, 
+space.newint(flags))
 if space.isinstance_w(w_result, space.w_buffer):
 return w_result.buffer_w(space, flags)
 raise BufferInterfaceNotFound
@@ -216,7 +217,8 @@
 def readbuf_w(self, space):
 w_impl = space.lookup(self, '__buffer__')
 if w_impl is not None:
-w_result = space.get_and_call_function(w_impl, self)
+w_result = space.get_and_call_function(w_impl, self,
+space.newint(space.BUF_FULL_RO))
 if space.isinstance_w(w_result, space.w_buffer):
 return w_result.readbuf_w(space)
 raise BufferInterfaceNotFound
@@ -224,7 +226,8 @@
 def writebuf_w(self, space):
 w_impl = space.lookup(self, '__buffer__')
 if w_impl is not None:
-w_result = space.get_and_call_function(w_impl, self)
+w_result = space.get_and_call_function(w_impl, self,
+space.newint(space.BUF_FULL))
 if space.isinstance_w(w_result, space.w_buffer):
 return w_result.writebuf_w(space)
 raise BufferInterfaceNotFound
@@ -232,7 +235,8 @@
 def charbuf_w(self, space):
 w_impl = space.lookup(self, '__buffer__')
 if w_impl is not None:
-w_result = space.get_and_call_function(w_impl, self)
+w_result = space.get_and_call_function(w_impl, self,
+space.newint(space.BUF_FULL_RO))
 if space.isinstance_w(w_result, space.w_buffer):
 return w_result.charbuf_w(space)
 raise BufferInterfaceNotFound
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -121,7 +121,7 @@
 Py_TPFLAGS_READY Py_TPFLAGS_READYING Py_TPFLAGS_HAVE_GETCHARBUFFER
 METH_COEXIST METH_STATIC METH_CLASS Py_TPFLAGS_BASETYPE
 METH_NOARGS METH_VARARGS METH_KEYWORDS METH_O
-Py_TPFLAGS_HEAPTYPE Py_TPFLAGS_HAVE_CLASS
+Py_TPFLAGS_HEAPTYPE Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_HAVE_NEWBUFFER
 Py_LT Py_LE Py_EQ Py_NE Py_GT Py_GE Py_TPFLAGS_CHECKTYPES
 """.split()
 for name in constant_names:
@@ -649,6 +649,7 @@
 #('smalltable', rffi.CFixedArray(Py_ssize_t, 2)),
 ('internal', rffi.VOIDP)
 ))
+Py_bufferP = lltype.Ptr(Py_buffer)
 
 @specialize.memo()
 def is_PyObject(TYPE):
diff --git a/pypy/module/cpyext/buffer.py b/pypy/module/cpyext/buffer.py
--- a/pypy/module/cpyext/buffer.py
+++ b/pypy/module/cpyext/buffer.py
@@ -1,13 +1,17 @@
 from pypy.interpreter.error import oefmt
 from rpython.rtyper.lltypesystem import rffi, lltype
 from pypy.module.cpyext.api import (
-cpython_api, CANNOT_FAIL, Py_buffer)
+cpython_api, CANNOT_FAIL, Py_buffer, Py_TPFLAGS_HAVE_NEWBUFFER)
 from pypy.module.cpyext.pyobject import PyObject
 
 @cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
-def PyObject_CheckBuffer(space, w_obj):
+def PyObject_CheckBuffer(space, pyobj):
 """Return 1 if obj supports the buffer interface otherwise 0."""
-return 0  # the bf_getbuffer field is never filled by cpyext
+as_buffer = pyobj.c_ob_type.c_tp_as_buffer
+flags = pyobj.c_ob_type.c_tp_flags
+if (flags & Py_TPFLAGS_HAVE_NEWBUFFER and as_buffer.c_bf_getbuffer):
+return 1
+return 0  
 
 @cpython_api([PyObject, lltype.Ptr(Py_buffer), rffi.INT_real],
  rffi.INT_real, error=-1)
diff --git a/pypy/module/cpyext/memoryobject.py 
b/pypy/module/cpyext/memoryobject.py
--- a/pypy/module/cpyext/memoryobject.py
+++ b/pypy/module/cpyext/memoryobject.py
@@ -12,7 +12,7 @@
 @cpython_api([PyObject], PyObject)
 def PyMemoryView_GET_BASE(space, w_obj):
 # return the obj field of the Py_buffer created by PyMemoryView_GET_BUFFER
-raise NotImplementedError
+raise NotImplementedError('PyMemoryView_GET_BUFFER')
 
 @cpython_api([PyObject], lltype.Ptr(Py_buffer), error=CANNOT_FAIL)
 def PyMemoryView_GET_BUFFER(space, w_obj):

[pypy-commit] pypy default: document branch

2016-08-24 Thread plan_rich
Author: Richard Plangger 
Branch: 
Changeset: r86457:951e70bd2fa1
Date: 2016-08-24 09:13 +0200
http://bitbucket.org/pypy/pypy/changeset/951e70bd2fa1/

Log:document branch

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
@@ -150,3 +150,8 @@
 
 Reduce the size of the generated C code by constant-folding ``we_are_jitted``
 in non-jitcode.
+
+.. branch: memoryview-attributes
+
+Support for memoryview attributes (format, itemsize, ...).
+Extends the cpyext emulation layer.
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit