[pypy-commit] pypy py3.5: merged default

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89433:8f58de1af422
Date: 2017-01-09 11:01 +0100
http://bitbucket.org/pypy/pypy/changeset/8f58de1af422/

Log:merged default

diff --git a/lib-python/2.7/ctypes/test/test_frombuffer.py 
b/lib-python/2.7/ctypes/test/test_frombuffer.py
--- a/lib-python/2.7/ctypes/test/test_frombuffer.py
+++ b/lib-python/2.7/ctypes/test/test_frombuffer.py
@@ -32,7 +32,7 @@
 del a; gc.collect(); gc.collect(); gc.collect()
 self.assertEqual(x[:], expected)
 
-self.assertRaises((TypeError, ValueError),
+self.assertRaises(TypeError,
   (c_char * 16).from_buffer, "a" * 16)
 
 def test_fom_buffer_with_offset(self):
diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -428,11 +428,6 @@
   ``datetime.date`` is the superclass of ``datetime.datetime``).
   Anyway, the proper fix is arguably to use a regular method call in
   the first place: ``datetime.date.today().strftime(...)``
-
-* the ``__dict__`` attribute of new-style classes returns a normal dict, as
-  opposed to a dict proxy like in CPython. Mutating the dict will change the
-  type and vice versa. For builtin types, a dictionary will be returned that
-  cannot be changed (but still looks and behaves like a normal dictionary).
   
 * some functions and attributes of the ``gc`` module behave in a
   slightly different way: for example, ``gc.enable`` and
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
@@ -90,3 +90,18 @@
 
 Support translations of cpyext with the Boehm GC (for special cases like
 revdb).
+
+.. branch: strbuf-as-buffer
+
+Implement StringBuffer.get_raw_address (missing feature for the buffer 
protocol).
+More generally it is now possible to obtain the address of any object (if it
+is readonly) without pinning it.
+
+.. branch: cpyext-cleanup
+
+Refactor cpyext initialisation.
+
+.. branch: cpyext-from2
+
+Fix a test failure introduced by strbuf-as-buffer
+
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -662,9 +662,6 @@
 
 def setup_builtin_modules(self):
 "NOT_RPYTHON: only for initializing the space."
-if self.config.objspace.usemodules.cpyext:
-from pypy.module.cpyext.state import State
-self.fromcache(State).build_api(self)
 self.getbuiltinmodule('sys')
 self.getbuiltinmodule('_imp')
 self.getbuiltinmodule('_frozen_importlib')
diff --git a/pypy/module/__pypy__/bytebuffer.py 
b/pypy/module/__pypy__/bytebuffer.py
--- a/pypy/module/__pypy__/bytebuffer.py
+++ b/pypy/module/__pypy__/bytebuffer.py
@@ -4,6 +4,7 @@
 
 from rpython.rlib.buffer import Buffer
 from pypy.interpreter.gateway import unwrap_spec
+from rpython.rlib.rgc import nonmoving_raw_ptr_for_resizable_list
 
 
 class ByteBuffer(Buffer):
@@ -22,6 +23,8 @@
 def setitem(self, index, char):
 self.data[index] = char
 
+def get_raw_address(self):
+return nonmoving_raw_ptr_for_resizable_list(self.data)
 
 @unwrap_spec(length=int)
 def bytebuffer(space, length):
diff --git a/pypy/module/_cffi_backend/func.py 
b/pypy/module/_cffi_backend/func.py
--- a/pypy/module/_cffi_backend/func.py
+++ b/pypy/module/_cffi_backend/func.py
@@ -136,6 +136,9 @@
 return _from_buffer(space, w_ctype, w_x)
 
 def _from_buffer(space, w_ctype, w_x):
+if space.isinstance_w(w_x, space.w_unicode):
+raise oefmt(space.w_TypeError,
+"from_buffer() cannot return the address a unicode")
 buf = _fetch_as_read_buffer(space, w_x)
 if space.isinstance_w(w_x, space.w_str):
 _cdata = get_raw_address_of_string(space, w_x)
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py 
b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -3427,16 +3427,26 @@
 except ImportError:
 pass
 else:
-# from_buffer(buffer(b"foo")) does not work, because it's not
-# implemented on pypy; only from_buffer(b"foo") works.
-py.test.raises(TypeError, from_buffer, BCharA, buffer(b"foo"))
-py.test.raises(TypeError, from_buffer, BCharA, buffer(u+"foo"))
+# Python 2 only
+contents = from_buffer(BCharA, buffer(b"foo"))
+assert len(contents) == len(p1)
+for i in range(len(contents)):
+assert contents[i] == p1[i]
+p4 = buffer(u+"foo")
+contents = from_buffer(BCharA, buffer(u+"foo"))
+assert len(contents) == len(p4)
+for i in range(len(contents)):
+assert contents[i] == p4[i]
 try:
 from __builtin__ import memoryview
 except ImportError:
 pass

[pypy-commit] pypy py3.5: spaces instead of tabs

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89434:3aca47a57d23
Date: 2017-01-09 11:13 +0100
http://bitbucket.org/pypy/pypy/changeset/3aca47a57d23/

Log:spaces instead of tabs

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
@@ -205,7 +205,7 @@
 The memoryview object then owns the buffer represented by view, which
 means you shouldn't try to call PyBuffer_Release() yourself: it
 will be done on deallocation of the memoryview object."""
-   assert view.c_obj
+assert view.c_obj
 w_obj = from_ref(space, view.c_obj)
 if isinstance(w_obj, W_MemoryView):
 return w_obj
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merge issure found

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89435:fd5118ae627c
Date: 2017-01-09 14:30 +0100
http://bitbucket.org/pypy/pypy/changeset/fd5118ae627c/

Log:merge issure found

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
@@ -525,7 +525,7 @@
 'PyCapsule_SetPointer', 'PyCapsule_SetName', 'PyCapsule_SetDestructor',
 'PyCapsule_SetContext', 'PyCapsule_Import', 'PyCapsule_Type', 
'_Py_get_capsule_type',
 
-'PyComplex_AsCComplex', 'PyComplex_FromCComplex',
+#'PyComplex_AsCComplex', 'PyComplex_FromCComplex',
 
 'PyObject_AsReadBuffer', 'PyObject_AsWriteBuffer', 
'PyObject_CheckReadBuffer',
 
@@ -1091,7 +1091,7 @@
 ptr.value = ctypes.cast(ll2ctypes.lltype2ctypes(value),
 ctypes.c_void_p).value
 elif typ in ('PyObject*', 'PyTypeObject*'):
-if name.startswith('PyPyExc_') or 
name.startswith('cpyexttestExc_'):
+if name.startswith('PyExc_'):
 # we already have the pointer
 in_dll = ll2ctypes.get_ctypes_type(PyObject).in_dll(bridge, 
mname)
 py_obj = ll2ctypes.ctypes2lltype(PyObject, in_dll)
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: memoryview(b"hello") == 104 != "h", 2to3

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: 
Changeset: r89436:aebaccb5bc42
Date: 2017-01-09 14:41 +0100
http://bitbucket.org/pypy/pypy/changeset/aebaccb5bc42/

Log:memoryview(b"hello") == 104 != "h", 2to3

diff --git a/pypy/module/cpyext/test/test_memoryobject.py 
b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -14,7 +14,7 @@
 assert api.PyObject_CheckBuffer(w_hello)
 w_view = from_ref(space, api.PyMemoryView_FromObject(w_hello))
 w_char = space.call_method(w_view, '__getitem__', space.wrap(0))
-assert space.eq_w(w_char, space.wrap('h'))
+assert space.eq_w(w_char, space.wrap(ord('h')))
 w_bytes = space.call_method(w_view, "tobytes")
 assert space.unwrap(w_bytes) == "hello"
 
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: comment PyObject_CheckBuffer check in test (was commented before merge as well)

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89437:99efa1c2bbd5
Date: 2017-01-09 14:59 +0100
http://bitbucket.org/pypy/pypy/changeset/99efa1c2bbd5/

Log:comment PyObject_CheckBuffer check in test (was commented before
merge as well)

diff --git a/pypy/module/cpyext/test/test_memoryobject.py 
b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -11,7 +11,7 @@
 class TestMemoryViewObject(BaseApiTest):
 def test_fromobject(self, space, api):
 w_hello = space.newbytes("hello")
-assert api.PyObject_CheckBuffer(w_hello)
+#assert api.PyObject_CheckBuffer(w_hello)
 w_view = from_ref(space, api.PyMemoryView_FromObject(w_hello))
 w_char = space.call_method(w_view, '__getitem__', space.wrap(0))
 assert space.eq_w(w_char, space.wrap('h'))
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5-time: close branch

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5-time
Changeset: r89439:fd3ba0d1944d
Date: 2017-01-09 15:08 +0100
http://bitbucket.org/pypy/pypy/changeset/fd3ba0d1944d/

Log:close branch

___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: merged py3.5-time changes

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89438:f58422e7ce44
Date: 2017-01-09 15:07 +0100
http://bitbucket.org/pypy/pypy/changeset/f58422e7ce44/

Log:merged py3.5-time changes

diff --git a/lib_pypy/_structseq.py b/lib_pypy/_structseq.py
--- a/lib_pypy/_structseq.py
+++ b/lib_pypy/_structseq.py
@@ -41,18 +41,25 @@
 assert field._index not in fields_by_index
 fields_by_index[field._index] = field
 field.__name__ = name
-dict['n_fields'] = len(fields_by_index)
+n_fields = len(fields_by_index)
+dict['n_fields'] = n_fields
 
 extra_fields = sorted(fields_by_index.items())
 n_sequence_fields = 0
-while extra_fields and extra_fields[0][0] == n_sequence_fields:
-extra_fields.pop(0)
-n_sequence_fields += 1
+invis_fields = []
+if 'n_sequence_fields' in dict:
+n_sequence_fields = dict['n_sequence_fields']
+extra_fields = extra_fields[n_sequence_fields:]
+else:
+while extra_fields and extra_fields[0][0] == n_sequence_fields:
+extra_fields.pop(0)
+n_sequence_fields += 1
+
 dict['n_sequence_fields'] = n_sequence_fields
 dict['n_unnamed_fields'] = 0 # no fully anonymous fields in PyPy
 
 extra_fields = [field for index, field in extra_fields]
-for field in extra_fields:
+for i,field in enumerate(extra_fields):
 field.index = None # no longer relevant
 
 assert '__new__' not in dict
@@ -70,34 +77,39 @@
 def structseq_new(cls, sequence, dict={}):
 sequence = tuple(sequence)
 dict = builtin_dict(dict)
-N = cls.n_sequence_fields
-if len(sequence) < N:
-if N < cls.n_fields:
+# visible fields
+visible_count = cls.n_sequence_fields
+# total fields (unnamed are not yet supported, extra fields not included)
+real_count = cls.n_fields
+length = len(sequence)
+if length < visible_count:
+if visible_count < real_count:
 msg = "at least"
 else:
 msg = "exactly"
-raise TypeError("expected a sequence with %s %d items" % (
-msg, N))
-if len(sequence) > N:
-if len(sequence) > cls.n_fields:
-if N < cls.n_fields:
+raise TypeError("expected a sequence with %s %d items. has %d" % (
+msg, visible_count, length))
+if length > visible_count:
+if length > real_count:
+if visible_count < real_count:
 msg = "at most"
 else:
 msg = "exactly"
-raise TypeError("expected a sequence with %s %d items" % (
-msg, cls.n_fields))
-for field, value in zip(cls._extra_fields, sequence[N:]):
+raise TypeError("expected a sequence with %s %d items. has %d" \
+% (msg, real_count, length))
+for field, value in zip(cls._extra_fields, sequence[visible_count:]):
 name = field.__name__
 if name in dict:
 raise TypeError("duplicate value for %r" % (name,))
 dict[name] = value
-sequence = sequence[:N]
+sequence = sequence[:visible_count]
 result = tuple.__new__(cls, sequence)
 object.__setattr__(result, '__dict__', dict)
 for field in cls._extra_fields:
 name = field.__name__
 if name not in dict:
 dict[name] = field._default(result)
+
 return result
 
 def structseq_reduce(self):
@@ -109,9 +121,11 @@
 
 def structseq_repr(self):
 fields = {}
+visible_count = self.n_sequence_fields
 for field in type(self).__dict__.values():
-if isinstance(field, structseqfield):
+if isinstance(field, structseqfield) and \
+   field._index <= visible_count:
 fields[field._index] = field
 parts = ["%s=%r" % (fields[index].__name__, value)
- for index, value in enumerate(self)]
+for index, value in enumerate(self[:visible_count])]
 return "%s(%s)" % (self._name, ", ".join(parts))
diff --git a/pypy/module/time/app_time.py b/pypy/module/time/app_time.py
--- a/pypy/module/time/app_time.py
+++ b/pypy/module/time/app_time.py
@@ -3,19 +3,26 @@
 from _structseq import structseqtype, structseqfield
 from types import SimpleNamespace
 import time
+
 class struct_time(metaclass=structseqtype):
 __module__ = 'time'
 name = 'time.struct_time'
 
-tm_year   = structseqfield(0)
-tm_mon= structseqfield(1)
-tm_mday   = structseqfield(2)
-tm_hour   = structseqfield(3)
-tm_min= structseqfield(4)
-tm_sec= structseqfield(5)
-tm_wday   = structseqfield(6)
-tm_yday   = structseqfield(7)
-tm_isdst  = structseqfield(8)
+n_sequence_fields = 9
+
+tm_year   = structseqfield(0, "year, for example, 1993")
+tm_mon= structseqfield(1, "month of year, range [1, 12]")
+tm_m

[pypy-commit] pypy py3.5: add two branches to thasnew pypy3

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89440:ec81607f0874
Date: 2017-01-09 15:08 +0100
http://bitbucket.org/pypy/pypy/changeset/ec81607f0874/

Log:add two branches to thasnew pypy3

diff --git a/pypy/doc/whatsnew-pypy3-head.rst b/pypy/doc/whatsnew-pypy3-head.rst
--- a/pypy/doc/whatsnew-pypy3-head.rst
+++ b/pypy/doc/whatsnew-pypy3-head.rst
@@ -33,3 +33,6 @@
 
 .. branch: py3k-update
 
+.. branch: py3.5-time
+
+.. branch: py3.5-ssl
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: do not use BaseImportTest as baseclass for zipimport tests (this class was removed)

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89441:21a8a2cfa452
Date: 2017-01-09 15:33 +0100
http://bitbucket.org/pypy/pypy/changeset/21a8a2cfa452/

Log:do not use BaseImportTest as baseclass for zipimport tests (this
class was removed)

diff --git a/pypy/module/zipimport/test/test_zipimport.py 
b/pypy/module/zipimport/test/test_zipimport.py
--- a/pypy/module/zipimport/test/test_zipimport.py
+++ b/pypy/module/zipimport/test/test_zipimport.py
@@ -4,11 +4,10 @@
 import time
 from zipfile import ZIP_STORED
 
-from pypy.module.imp.test.support import BaseImportTest
 from rpython.tool.udir import udir
 
 
-class AppTestZipimport(BaseImportTest):
+class AppTestZipimport:
 """ A bit structurized tests stolen and adapted from
 cpy's regression tests
 """
@@ -20,7 +19,6 @@
 
 @classmethod
 def make_class(cls):
-BaseImportTest.setup_class.im_func(cls)
 space = cls.space
 w = space.wrap
 
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: readd PyComplex_AsCComplex & PyComplex_FromCComplex to C_SYMBOLS

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89443:3e07ac8b799c
Date: 2017-01-09 15:55 +0100
http://bitbucket.org/pypy/pypy/changeset/3e07ac8b799c/

Log:readd PyComplex_AsCComplex & PyComplex_FromCComplex to C_SYMBOLS

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
@@ -525,7 +525,7 @@
 'PyCapsule_SetPointer', 'PyCapsule_SetName', 'PyCapsule_SetDestructor',
 'PyCapsule_SetContext', 'PyCapsule_Import', 'PyCapsule_Type', 
'_Py_get_capsule_type',
 
-#'PyComplex_AsCComplex', 'PyComplex_FromCComplex',
+'PyComplex_AsCComplex', 'PyComplex_FromCComplex',
 
 'PyObject_AsReadBuffer', 'PyObject_AsWriteBuffer', 
'PyObject_CheckReadBuffer',
 
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: use BaseFSEncodeTest instead (support file was moved), this seems like a merge conflict introduced long ago

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89442:01b498518160
Date: 2017-01-09 15:52 +0100
http://bitbucket.org/pypy/pypy/changeset/01b498518160/

Log:use BaseFSEncodeTest instead (support file was moved), this seems
like a merge conflict introduced long ago

diff --git a/pypy/module/zipimport/test/test_zipimport.py 
b/pypy/module/zipimport/test/test_zipimport.py
--- a/pypy/module/zipimport/test/test_zipimport.py
+++ b/pypy/module/zipimport/test/test_zipimport.py
@@ -4,10 +4,11 @@
 import time
 from zipfile import ZIP_STORED
 
+from pypy.interpreter.test.test_fsencode import BaseFSEncodeTest
 from rpython.tool.udir import udir
 
 
-class AppTestZipimport:
+class AppTestZipimport(BaseFSEncodeTest):
 """ A bit structurized tests stolen and adapted from
 cpy's regression tests
 """
@@ -19,6 +20,7 @@
 
 @classmethod
 def make_class(cls):
+BaseFSEncodeTest.setup_class.im_func(cls)
 space = cls.space
 w = space.wrap
 
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: cpyext compile sources in complexobject.c

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89444:c32c88be4363
Date: 2017-01-09 16:07 +0100
http://bitbucket.org/pypy/pypy/changeset/c32c88be4363/

Log:cpyext compile sources in complexobject.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
@@ -1253,6 +1253,7 @@
  source_dir / "missing.c",
  source_dir / "pymem.c",
  source_dir / "bytesobject.c",
+ source_dir / "complexobject.c",
  ]
 
 def build_eci(code, use_micronumpy=False, translating=False):
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: add b prefix to string to pass bytes for this test

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: 
Changeset: r89445:245faec2ea07
Date: 2017-01-09 17:01 +0100
http://bitbucket.org/pypy/pypy/changeset/245faec2ea07/

Log:add b prefix to string to pass bytes for this test

diff --git a/pypy/objspace/std/test/test_memoryobject.py 
b/pypy/objspace/std/test/test_memoryobject.py
--- a/pypy/objspace/std/test/test_memoryobject.py
+++ b/pypy/objspace/std/test/test_memoryobject.py
@@ -56,7 +56,7 @@
 assert u"abc" != memoryview("abc")
 
 def test_pypy_raw_address_base(self):
-a = memoryview("foobar")._pypy_raw_address()
+a = memoryview(b"foobar")._pypy_raw_address()
 assert a != 0
-b = memoryview(bytearray("foobar"))._pypy_raw_address()
+b = memoryview(bytearray(b"foobar"))._pypy_raw_address()
 assert b != 0
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


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

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: py3.5
Changeset: r89446:596ff2168cf5
Date: 2017-01-09 17:01 +0100
http://bitbucket.org/pypy/pypy/changeset/596ff2168cf5/

Log:merge default

diff --git a/pypy/module/cpyext/test/test_memoryobject.py 
b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -14,7 +14,7 @@
 #assert api.PyObject_CheckBuffer(w_hello)
 w_view = from_ref(space, api.PyMemoryView_FromObject(w_hello))
 w_char = space.call_method(w_view, '__getitem__', space.wrap(0))
-assert space.eq_w(w_char, space.wrap('h'))
+assert space.eq_w(w_char, space.wrap(ord('h')))
 w_bytes = space.call_method(w_view, "tobytes")
 assert space.unwrap(w_bytes) == "hello"
 
diff --git a/pypy/objspace/std/test/test_memoryobject.py 
b/pypy/objspace/std/test/test_memoryobject.py
--- a/pypy/objspace/std/test/test_memoryobject.py
+++ b/pypy/objspace/std/test/test_memoryobject.py
@@ -185,9 +185,9 @@
 assert m[2] == 1
 
 def test_pypy_raw_address_base(self):
-a = memoryview("foobar")._pypy_raw_address()
+a = memoryview(b"foobar")._pypy_raw_address()
 assert a != 0
-b = memoryview(bytearray("foobar"))._pypy_raw_address()
+b = memoryview(bytearray(b"foobar"))._pypy_raw_address()
 assert b != 0
 
 def test_hex(self):
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: revert aebaccb5bc42, checked in on wrong branch

2017-01-09 Thread plan_rich
Author: Richard Plangger 
Branch: 
Changeset: r89447:43b0e50c2403
Date: 2017-01-09 18:24 +0100
http://bitbucket.org/pypy/pypy/changeset/43b0e50c2403/

Log:revert aebaccb5bc42, checked in on wrong branch

diff --git a/pypy/module/cpyext/test/test_memoryobject.py 
b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -14,7 +14,7 @@
 assert api.PyObject_CheckBuffer(w_hello)
 w_view = from_ref(space, api.PyMemoryView_FromObject(w_hello))
 w_char = space.call_method(w_view, '__getitem__', space.wrap(0))
-assert space.eq_w(w_char, space.wrap(ord('h')))
+assert space.eq_w(w_char, space.wrap('h'))
 w_bytes = space.call_method(w_view, "tobytes")
 assert space.unwrap(w_bytes) == "hello"
 
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Regenerate unicodedb versions 6.1.0 and 6.2.0 with a fixed cjk_interval

2017-01-09 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r89448:dc1ce991bcaf
Date: 2017-01-09 18:37 +0100
http://bitbucket.org/pypy/pypy/changeset/dc1ce991bcaf/

Log:Regenerate unicodedb versions 6.1.0 and 6.2.0 with a fixed
cjk_interval

diff --git a/rpython/rlib/unicodedata/generate_unicodedb.py 
b/rpython/rlib/unicodedata/generate_unicodedb.py
--- a/rpython/rlib/unicodedata/generate_unicodedb.py
+++ b/rpython/rlib/unicodedata/generate_unicodedb.py
@@ -569,9 +569,15 @@
 " 0x4E00 <= code <= 0x9FCB or"
 " 0x2 <= code <= 0x2A6D6 or"
 " 0x2A700 <= code <= 0x2B734)")
+elif version < "6.1":
+cjk_interval = ("(0x3400 <= code <= 0x4DB5 or"
+" 0x4E00 <= code <= 0x9FCB or"
+" 0x2 <= code <= 0x2A6D6 or"
+" 0x2A700 <= code <= 0x2B734 or"
+" 0x2B740 <= code <= 0x2B81D)")
 else:
 cjk_interval = ("(0x3400 <= code <= 0x4DB5 or"
-" 0x4E00 <= code <= 0x9FCB or"
+" 0x4E00 <= code <= 0x9FCC or"
 " 0x2 <= code <= 0x2A6D6 or"
 " 0x2A700 <= code <= 0x2B734 or"
 " 0x2B740 <= code <= 0x2B81D)")
diff --git a/rpython/rlib/unicodedata/unicodedb_6_1_0.py 
b/rpython/rlib/unicodedata/unicodedb_6_1_0.py
--- a/rpython/rlib/unicodedata/unicodedb_6_1_0.py
+++ b/rpython/rlib/unicodedata/unicodedb_6_1_0.py
@@ -6882,7 +6882,7 @@
 if not ('0' <= c <= '9' or 'A' <= c <= 'F'):
 raise KeyError
 code = int(cjk_code, 16)
-if (0x3400 <= code <= 0x4DB5 or 0x4E00 <= code <= 0x9FCB or 0x2 <= 
code <= 0x2A6D6 or 0x2A700 <= code <= 0x2B734 or 0x2B740 <= code <= 0x2B81D):
+if (0x3400 <= code <= 0x4DB5 or 0x4E00 <= code <= 0x9FCC or 0x2 <= 
code <= 0x2A6D6 or 0x2A700 <= code <= 0x2B734 or 0x2B740 <= code <= 0x2B81D):
 return code
 raise KeyError
 
@@ -6907,7 +6907,7 @@
 return code
 
 def name(code):
-if (0x3400 <= code <= 0x4DB5 or 0x4E00 <= code <= 0x9FCB or 0x2 <= 
code <= 0x2A6D6 or 0x2A700 <= code <= 0x2B734 or 0x2B740 <= code <= 0x2B81D):
+if (0x3400 <= code <= 0x4DB5 or 0x4E00 <= code <= 0x9FCC or 0x2 <= 
code <= 0x2A6D6 or 0x2A700 <= code <= 0x2B734 or 0x2B740 <= code <= 0x2B81D):
 return "CJK UNIFIED IDEOGRAPH-" + hex(code)[2:].upper()
 if 0xAC00 <= code <= 0xD7A3:
 # vl_code, t_code = divmod(code - 0xAC00, len(_hangul_T))
diff --git a/rpython/rlib/unicodedata/unicodedb_6_2_0.py 
b/rpython/rlib/unicodedata/unicodedb_6_2_0.py
--- a/rpython/rlib/unicodedata/unicodedb_6_2_0.py
+++ b/rpython/rlib/unicodedata/unicodedb_6_2_0.py
@@ -6886,7 +6886,7 @@
 if not ('0' <= c <= '9' or 'A' <= c <= 'F'):
 raise KeyError
 code = int(cjk_code, 16)
-if (0x3400 <= code <= 0x4DB5 or 0x4E00 <= code <= 0x9FCB or 0x2 <= 
code <= 0x2A6D6 or 0x2A700 <= code <= 0x2B734 or 0x2B740 <= code <= 0x2B81D):
+if (0x3400 <= code <= 0x4DB5 or 0x4E00 <= code <= 0x9FCC or 0x2 <= 
code <= 0x2A6D6 or 0x2A700 <= code <= 0x2B734 or 0x2B740 <= code <= 0x2B81D):
 return code
 raise KeyError
 
@@ -6911,7 +6911,7 @@
 return code
 
 def name(code):
-if (0x3400 <= code <= 0x4DB5 or 0x4E00 <= code <= 0x9FCB or 0x2 <= 
code <= 0x2A6D6 or 0x2A700 <= code <= 0x2B734 or 0x2B740 <= code <= 0x2B81D):
+if (0x3400 <= code <= 0x4DB5 or 0x4E00 <= code <= 0x9FCC or 0x2 <= 
code <= 0x2A6D6 or 0x2A700 <= code <= 0x2B734 or 0x2B740 <= code <= 0x2B81D):
 return "CJK UNIFIED IDEOGRAPH-" + hex(code)[2:].upper()
 if 0xAC00 <= code <= 0xD7A3:
 # vl_code, t_code = divmod(code - 0xAC00, len(_hangul_T))
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Add version 8.0.0 of the unicode database (for 3.5)

2017-01-09 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r89449:17b03637ebc2
Date: 2017-01-09 18:54 +0100
http://bitbucket.org/pypy/pypy/changeset/17b03637ebc2/

Log:Add version 8.0.0 of the unicode database (for 3.5)

Note that CPython uses DerivedNormalizationProps-x.x.x.txt at least
since 3.2, which is missing here.

diff too long, truncating to 2000 out of 70274 lines

diff --git a/rpython/rlib/unicodedata/CaseFolding-8.0.0.txt 
b/rpython/rlib/unicodedata/CaseFolding-8.0.0.txt
new file mode 100644
--- /dev/null
+++ b/rpython/rlib/unicodedata/CaseFolding-8.0.0.txt
@@ -0,0 +1,1414 @@
+# CaseFolding-8.0.0.txt
+# Date: 2015-01-13, 18:16:36 GMT [MD]
+#
+# Unicode Character Database
+# Copyright (c) 1991-2015 Unicode, Inc.
+# For terms of use, see http://www.unicode.org/terms_of_use.html
+# For documentation, see http://www.unicode.org/reports/tr44/
+#
+# Case Folding Properties
+#
+# This file is a supplement to the UnicodeData file.
+# It provides a case folding mapping generated from the Unicode Character 
Database.
+# If all characters are mapped according to the full mapping below, then
+# case differences (according to UnicodeData.txt and SpecialCasing.txt)
+# are eliminated.
+#
+# The data supports both implementations that require simple case foldings
+# (where string lengths don't change), and implementations that allow full 
case folding
+# (where string lengths may grow). Note that where they can be supported, the
+# full case foldings are superior: for example, they allow "MASSE" and 
"Maße" to match.
+#
+# All code points not listed in this file map to themselves.
+#
+# NOTE: case folding does not preserve normalization formats!
+#
+# For information on case folding, including how to have case folding 
+# preserve normalization formats, see Section 3.13 Default Case Algorithms in
+# The Unicode Standard.
+#
+# 

+# Format
+# 

+# The entries in this file are in the following machine-readable format:
+#
+# ; ; ; # 
+#
+# The status field is:
+# C: common case folding, common mappings shared by both simple and full 
mappings.
+# F: full case folding, mappings that cause strings to grow in length. 
Multiple characters are separated by spaces.
+# S: simple case folding, mappings to single characters where different from F.
+# T: special case for uppercase I and dotted uppercase I
+#- For non-Turkic languages, this mapping is normally not used.
+#- For Turkic languages (tr, az), this mapping can be used instead of the 
normal mapping for these characters.
+#  Note that the Turkic mappings do not maintain canonical equivalence 
without additional processing.
+#  See the discussions of case mapping in the Unicode Standard for more 
information.
+#
+# Usage:
+#  A. To do a simple case folding, use the mappings with status C + S.
+#  B. To do a full case folding, use the mappings with status C + F.
+#
+#The mappings with status T can be used or omitted depending on the 
desired case-folding
+#behavior. (The default option is to exclude them.)
+#
+# =
+
+# Property: Case_Folding
+
+#  All code points not explicitly listed for Case_Folding
+#  have the value C for the status field, and the code point itself for the 
mapping field.
+
+# =
+0041; C; 0061; # LATIN CAPITAL LETTER A
+0042; C; 0062; # LATIN CAPITAL LETTER B
+0043; C; 0063; # LATIN CAPITAL LETTER C
+0044; C; 0064; # LATIN CAPITAL LETTER D
+0045; C; 0065; # LATIN CAPITAL LETTER E
+0046; C; 0066; # LATIN CAPITAL LETTER F
+0047; C; 0067; # LATIN CAPITAL LETTER G
+0048; C; 0068; # LATIN CAPITAL LETTER H
+0049; C; 0069; # LATIN CAPITAL LETTER I
+0049; T; 0131; # LATIN CAPITAL LETTER I
+004A; C; 006A; # LATIN CAPITAL LETTER J
+004B; C; 006B; # LATIN CAPITAL LETTER K
+004C; C; 006C; # LATIN CAPITAL LETTER L
+004D; C; 006D; # LATIN CAPITAL LETTER M
+004E; C; 006E; # LATIN CAPITAL LETTER N
+004F; C; 006F; # LATIN CAPITAL LETTER O
+0050; C; 0070; # LATIN CAPITAL LETTER P
+0051; C; 0071; # LATIN CAPITAL LETTER Q
+0052; C; 0072; # LATIN CAPITAL LETTER R
+0053; C; 0073; # LATIN CAPITAL LETTER S
+0054; C; 0074; # LATIN CAPITAL LETTER T
+0055; C; 0075; # LATIN CAPITAL LETTER U
+0056; C; 0076; # LATIN CAPITAL LETTER V
+0057; C; 0077; # LATIN CAPITAL LETTER W
+0058; C; 0078; # LATIN CAPITAL LETTER X
+0059; C; 0079; # LATIN CAPITAL LETTER Y
+005A; C; 007A; # LATIN CAPITAL LETTER Z
+00B5; C; 03BC; # MICRO SIGN
+00C0; C; 00E0; # LATIN CAPITAL LETTER A WITH GRAVE
+00C1; C; 00E1; # LATIN CAPITAL LETTER A WITH ACUTE
+00C2; C; 00E2; # LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+00C3; C; 00E3; # LATIN CAPITAL LETTER A WITH TILDE
+00C4; C; 00E4; # LATIN CAPITAL LETTER A WITH DIAERESIS
+00C5; C; 00E5; # LATIN CAPITAL LETTER A WITH RING ABOVE
+00C6; C; 00E6; # LATIN CA

[pypy-commit] pypy py3.5: hg merge default

2017-01-09 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r89451:3708a9cce7d6
Date: 2017-01-09 19:00 +0100
http://bitbucket.org/pypy/pypy/changeset/3708a9cce7d6/

Log:hg merge default

diff too long, truncating to 2000 out of 70334 lines

diff --git a/pypy/module/cpyext/test/test_memoryobject.py 
b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -14,7 +14,7 @@
 #assert api.PyObject_CheckBuffer(w_hello)
 w_view = from_ref(space, api.PyMemoryView_FromObject(w_hello))
 w_char = space.call_method(w_view, '__getitem__', space.wrap(0))
-assert space.eq_w(w_char, space.wrap(ord('h')))
+assert space.eq_w(w_char, space.wrap('h'))
 w_bytes = space.call_method(w_view, "tobytes")
 assert space.unwrap(w_bytes) == "hello"
 
diff --git a/rpython/rlib/unicodedata/CaseFolding-8.0.0.txt 
b/rpython/rlib/unicodedata/CaseFolding-8.0.0.txt
new file mode 100644
--- /dev/null
+++ b/rpython/rlib/unicodedata/CaseFolding-8.0.0.txt
@@ -0,0 +1,1414 @@
+# CaseFolding-8.0.0.txt
+# Date: 2015-01-13, 18:16:36 GMT [MD]
+#
+# Unicode Character Database
+# Copyright (c) 1991-2015 Unicode, Inc.
+# For terms of use, see http://www.unicode.org/terms_of_use.html
+# For documentation, see http://www.unicode.org/reports/tr44/
+#
+# Case Folding Properties
+#
+# This file is a supplement to the UnicodeData file.
+# It provides a case folding mapping generated from the Unicode Character 
Database.
+# If all characters are mapped according to the full mapping below, then
+# case differences (according to UnicodeData.txt and SpecialCasing.txt)
+# are eliminated.
+#
+# The data supports both implementations that require simple case foldings
+# (where string lengths don't change), and implementations that allow full 
case folding
+# (where string lengths may grow). Note that where they can be supported, the
+# full case foldings are superior: for example, they allow "MASSE" and 
"Maße" to match.
+#
+# All code points not listed in this file map to themselves.
+#
+# NOTE: case folding does not preserve normalization formats!
+#
+# For information on case folding, including how to have case folding 
+# preserve normalization formats, see Section 3.13 Default Case Algorithms in
+# The Unicode Standard.
+#
+# 

+# Format
+# 

+# The entries in this file are in the following machine-readable format:
+#
+# ; ; ; # 
+#
+# The status field is:
+# C: common case folding, common mappings shared by both simple and full 
mappings.
+# F: full case folding, mappings that cause strings to grow in length. 
Multiple characters are separated by spaces.
+# S: simple case folding, mappings to single characters where different from F.
+# T: special case for uppercase I and dotted uppercase I
+#- For non-Turkic languages, this mapping is normally not used.
+#- For Turkic languages (tr, az), this mapping can be used instead of the 
normal mapping for these characters.
+#  Note that the Turkic mappings do not maintain canonical equivalence 
without additional processing.
+#  See the discussions of case mapping in the Unicode Standard for more 
information.
+#
+# Usage:
+#  A. To do a simple case folding, use the mappings with status C + S.
+#  B. To do a full case folding, use the mappings with status C + F.
+#
+#The mappings with status T can be used or omitted depending on the 
desired case-folding
+#behavior. (The default option is to exclude them.)
+#
+# =
+
+# Property: Case_Folding
+
+#  All code points not explicitly listed for Case_Folding
+#  have the value C for the status field, and the code point itself for the 
mapping field.
+
+# =
+0041; C; 0061; # LATIN CAPITAL LETTER A
+0042; C; 0062; # LATIN CAPITAL LETTER B
+0043; C; 0063; # LATIN CAPITAL LETTER C
+0044; C; 0064; # LATIN CAPITAL LETTER D
+0045; C; 0065; # LATIN CAPITAL LETTER E
+0046; C; 0066; # LATIN CAPITAL LETTER F
+0047; C; 0067; # LATIN CAPITAL LETTER G
+0048; C; 0068; # LATIN CAPITAL LETTER H
+0049; C; 0069; # LATIN CAPITAL LETTER I
+0049; T; 0131; # LATIN CAPITAL LETTER I
+004A; C; 006A; # LATIN CAPITAL LETTER J
+004B; C; 006B; # LATIN CAPITAL LETTER K
+004C; C; 006C; # LATIN CAPITAL LETTER L
+004D; C; 006D; # LATIN CAPITAL LETTER M
+004E; C; 006E; # LATIN CAPITAL LETTER N
+004F; C; 006F; # LATIN CAPITAL LETTER O
+0050; C; 0070; # LATIN CAPITAL LETTER P
+0051; C; 0071; # LATIN CAPITAL LETTER Q
+0052; C; 0072; # LATIN CAPITAL LETTER R
+0053; C; 0073; # LATIN CAPITAL LETTER S
+0054; C; 0074; # LATIN CAPITAL LETTER T
+0055; C; 0075; # LATIN CAPITAL LETTER U
+0056; C; 0076; # LATIN CAPITAL LETTER V
+0057; C; 0077; # LATIN CAPITAL LETTER W
+0058; C; 0078

[pypy-commit] pypy py3.5: Update to use version 8.0.0 of the unicode database

2017-01-09 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r89452:b69ffcf2b98e
Date: 2017-01-09 19:04 +0100
http://bitbucket.org/pypy/pypy/changeset/b69ffcf2b98e/

Log:Update to use version 8.0.0 of the unicode database

diff --git a/pypy/module/unicodedata/interp_ucd.py 
b/pypy/module/unicodedata/interp_ucd.py
--- a/pypy/module/unicodedata/interp_ucd.py
+++ b/pypy/module/unicodedata/interp_ucd.py
@@ -9,7 +9,7 @@
 from rpython.rlib.rarithmetic import r_longlong
 from rpython.rlib.objectmodel import we_are_translated
 from rpython.rlib.runicode import MAXUNICODE
-from rpython.rlib.unicodedata import unicodedb_6_1_0, unicodedb_3_2_0
+from rpython.rlib.unicodedata import unicodedb_8_0_0, unicodedb_3_2_0
 from rpython.rlib.runicode import code_to_unichr, ord_accepts_surrogate
 import sys
 
@@ -334,5 +334,5 @@
   **methods)
 
 ucd_3_2_0 = UCD(unicodedb_3_2_0)
-ucd_6_1_0 = UCD(unicodedb_6_1_0)
-ucd = ucd_6_1_0
+ucd_8_0_0 = UCD(unicodedb_8_0_0)
+ucd = ucd_8_0_0
diff --git a/pypy/module/unicodedata/test/test_unicodedata.py 
b/pypy/module/unicodedata/test/test_unicodedata.py
--- a/pypy/module/unicodedata/test/test_unicodedata.py
+++ b/pypy/module/unicodedata/test/test_unicodedata.py
@@ -46,18 +46,18 @@
 def test_cjk(self):
 import sys
 import unicodedata
-cases = ((0x3400, 0x4DB5),
- (0x4E00, 0x9FA5))
-if unicodedata.unidata_version >= "5":# don't know the exact limit
-cases = ((0x3400, 0x4DB5),
- (0x4E00, 0x9FCB),
- (0x2, 0x2A6D6),
- (0x2A700, 0x2B734))
-elif unicodedata.unidata_version >= "4.1":
-cases = ((0x3400, 0x4DB5),
- (0x4E00, 0x9FBB),
- (0x2, 0x2A6D6))
+assert unicodedata.unidata_version >= "8"
+cases = [
+('3400', '4DB5'),
+('4E00', '9FD5'),
+('2', '2A6D6'),
+('2A700', '2B734'),
+('2B740', '2B81D'),
+('2B820', '2CEA1'),
+]
 for first, last in cases:
+first = int(first, 16)
+last = int(last, 16)
 # Test at and inside the boundary
 for i in (first, first + 1, last - 1, last):
 charname = 'CJK UNIFIED IDEOGRAPH-%X'%i
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy api_func-refactor: Move unwrapper creation to a method of ApiFunction()

2017-01-09 Thread rlamy
Author: Ronan Lamy 
Branch: api_func-refactor
Changeset: r89453:8d6b8422c3d2
Date: 2017-01-09 19:06 +
http://bitbucket.org/pypy/pypy/changeset/8d6b8422c3d2/

Log:Move unwrapper creation to a method of ApiFunction()

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
@@ -329,6 +329,53 @@
 wrapper.c_name = cpyext_namespace.uniquename(self.c_name)
 return wrapper
 
+def get_unwrapper(self):
+names = self.argnames
+argtypesw = zip(self.argtypes,
+[_name.startswith("w_") for _name in self.argnames])
+types_names_enum_ui = unrolling_iterable(enumerate(argtypesw))
+
[email protected]()
+def unwrapper(space, *args):
+from pypy.module.cpyext.pyobject import is_pyobj
+from pypy.module.cpyext.pyobject import from_ref, as_pyobj
+newargs = ()
+keepalives = ()
+assert len(args) == len(self.argtypes)
+for i, (ARG, is_wrapped) in types_names_enum_ui:
+input_arg = args[i]
+if is_PyObject(ARG) and not is_wrapped:
+# build a 'PyObject *' (not holding a reference)
+if not is_pyobj(input_arg):
+keepalives += (input_arg,)
+arg = rffi.cast(ARG, as_pyobj(space, input_arg))
+else:
+arg = rffi.cast(ARG, input_arg)
+elif ARG == rffi.VOIDP and not is_wrapped:
+# unlike is_PyObject case above, we allow any kind of
+# argument -- just, if it's an object, we assume the
+# caller meant for it to become a PyObject*.
+if input_arg is None or isinstance(input_arg, W_Root):
+keepalives += (input_arg,)
+arg = rffi.cast(ARG, as_pyobj(space, input_arg))
+else:
+arg = rffi.cast(ARG, input_arg)
+elif (is_PyObject(ARG) or ARG == rffi.VOIDP) and is_wrapped:
+# build a W_Root, possibly from a 'PyObject *'
+if is_pyobj(input_arg):
+arg = from_ref(space, input_arg)
+else:
+arg = input_arg
+else:
+# arg is not declared as PyObject, no magic
+arg = input_arg
+newargs += (arg, )
+try:
+return self.callable(space, *newargs)
+finally:
+keepalive_until_here(*keepalives)
+return unwrapper
+
 def get_c_restype(self, c_writer):
 return c_writer.gettype(self.restype).replace('@', '').strip()
 
@@ -452,67 +499,7 @@
 c_name=c_name, gil=gil,
 result_borrowed=result_borrowed,
 result_is_ll=result_is_ll)
-names = api_function.argnames
-types_names_enum_ui = unrolling_iterable(enumerate(
-zip(api_function.argtypes,
-[tp_name.startswith("w_") for tp_name in names])))
-
[email protected]()
-def unwrapper(space, *args):
-from pypy.module.cpyext.pyobject import Py_DecRef, is_pyobj
-from pypy.module.cpyext.pyobject import from_ref, as_pyobj
-newargs = ()
-keepalives = ()
-assert len(args) == len(api_function.argtypes)
-for i, (ARG, is_wrapped) in types_names_enum_ui:
-input_arg = args[i]
-if is_PyObject(ARG) and not is_wrapped:
-# build a 'PyObject *' (not holding a reference)
-if not is_pyobj(input_arg):
-keepalives += (input_arg,)
-arg = rffi.cast(ARG, as_pyobj(space, input_arg))
-else:
-arg = rffi.cast(ARG, input_arg)
-elif ARG == rffi.VOIDP and not is_wrapped:
-# unlike is_PyObject case above, we allow any kind of
-# argument -- just, if it's an object, we assume the
-# caller meant for it to become a PyObject*.
-if input_arg is None or isinstance(input_arg, W_Root):
-keepalives += (input_arg,)
-arg = rffi.cast(ARG, as_pyobj(space, input_arg))
-else:
-arg = rffi.cast(ARG, input_arg)
-elif (is_PyObject(ARG) or ARG == rffi.VOIDP) and is_wrapped:
-# build a W_Root, possibly from a 'PyObject *'
-if is_pyobj(input_arg):
-arg = from_ref(space, input_arg)
-else:
-arg = input_arg
-
-## ZZZ: for is_pyobj:
-## try:
-## arg = from_ref(space,
-##rffi.cast(PyObject, input_arg))

[pypy-commit] pypy py3.5: Add two cases, one passing and one obscure marked "XXX not implemented".

2017-01-09 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r89454:665c5772bb8a
Date: 2017-01-09 21:00 +0100
http://bitbucket.org/pypy/pypy/changeset/665c5772bb8a/

Log:Add two cases, one passing and one obscure marked "XXX not
implemented". Comment out the corresponding obscure case inside lib-
python/3/test/test_super.py.

diff --git a/lib-python/3/test/test_super.py b/lib-python/3/test/test_super.py
--- a/lib-python/3/test/test_super.py
+++ b/lib-python/3/test/test_super.py
@@ -94,11 +94,14 @@
 x = X()
 self.assertEqual(x.f(), 'A')
 self.assertEqual(x.__class__, 413)
-class X:
-x = __class__
-def f():
-__class__
-self.assertIs(X.x, type(self))
+# XXX the following reads the __class__ from a class body, which
+# XXX gives the one in the *parent* class (here, TestSuper).
+# XXX with PyPy it fails with a NameError instead for now.
+#class X:
+#x = __class__
+#def f():
+#__class__
+#self.assertIs(X.x, type(self))
 with self.assertRaises(NameError) as e:
 exec("""class X:
 __class__
diff --git a/pypy/interpreter/test/test_compiler.py 
b/pypy/interpreter/test/test_compiler.py
--- a/pypy/interpreter/test/test_compiler.py
+++ b/pypy/interpreter/test/test_compiler.py
@@ -405,7 +405,25 @@
 __class__ = 42
 def testing():
 return Y.__dict__['__class__']
-'''
+''', '''
+class X:
+foobar = 42
+def f(self):
+return __class__.__dict__['foobar']
+def testing():
+return X().f()
+''',
+#XXX the following case is not implemented for now
+#'''
+#class X:
+#foobar = 42
+#def f(self):
+#class Y:
+#Xcls = __class__
+#return Y.Xcls.__dict__['foobar']
+#def testing():
+#return X().f()
+#'''
 ]:
 space.call_args(w_filterwarnings, filter_arg)
 pycode = self.compiler.compile(code, '', 'exec', 0)
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy cpyext-FromBuffer: failing test, flesh out FillInfo

2017-01-09 Thread mattip
Author: Matti Picus 
Branch: cpyext-FromBuffer
Changeset: r89455:24f3f8187bfa
Date: 2017-01-09 22:17 +0200
http://bitbucket.org/pypy/pypy/changeset/24f3f8187bfa/

Log:failing test, flesh out FillInfo

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
@@ -124,6 +124,7 @@
 METH_NOARGS METH_VARARGS METH_KEYWORDS METH_O Py_TPFLAGS_HAVE_INPLACEOPS
 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_MAX_NDIMS
+PyBUF_FORMAT PyBUF_ND PyBUF_STRIDES
 """.split()
 for name in constant_names:
 setattr(CConfig_constants, name, rffi_platform.ConstantInteger(name))
diff --git a/pypy/module/cpyext/object.py b/pypy/module/cpyext/object.py
--- a/pypy/module/cpyext/object.py
+++ b/pypy/module/cpyext/object.py
@@ -1,7 +1,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from pypy.module.cpyext.api import (
 cpython_api, generic_cpy_call, CANNOT_FAIL, Py_ssize_t, Py_ssize_tP,
-PyVarObject, Py_buffer, size_t,
+PyVarObject, Py_buffer, size_t, PyBUF_FORMAT, PyBUF_ND, PyBUF_STRIDES,
 Py_TPFLAGS_HEAPTYPE, Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT,
 Py_GE, CONST_STRING, CONST_STRINGP, FILEP, fwrite)
 from pypy.module.cpyext.pyobject import (
@@ -486,22 +486,28 @@
 Fills in a buffer-info structure correctly for an exporter that can only
 share a contiguous chunk of memory of "unsigned bytes" of the given
 length. Returns 0 on success and -1 (with raising an error) on error.
-
-This is not a complete re-implementation of the CPython API; it only
-provides a subset of CPython's behavior.
 """
 if flags & PyBUF_WRITABLE and readonly:
 raise oefmt(space.w_ValueError, "Object is not writable")
 view.c_buf = buf
 view.c_len = length
 view.c_obj = obj
-Py_IncRef(space, obj)
+if obj:
+Py_IncRef(space, obj)
 view.c_itemsize = 1
 rffi.setintfield(view, 'c_readonly', readonly)
-rffi.setintfield(view, 'c_ndim', 0)
+rffi.setintfield(view, 'c_ndim', 1)
 view.c_format = lltype.nullptr(rffi.CCHARP.TO)
+if (flags & PyBUF_FORMAT) == PyBUF_FORMAT:
+view.c_format = rffi.str2charp("B")
 view.c_shape = lltype.nullptr(Py_ssize_tP.TO)
+if (flags & PyBUF_ND) == PyBUF_ND:
+view.c_shape = rffi.cast(Py_ssize_tP, view.c__shape)
+view.c_shape[0] = view.c_len
 view.c_strides = lltype.nullptr(Py_ssize_tP.TO)
+if (flags & PyBUF_STRIDES) == PyBUF_STRIDES:
+view.c_strides = rffi.cast(Py_ssize_tP, view.c__strides)
+view.c_strides[0] = view.c_itemsize
 view.c_suboffsets = lltype.nullptr(Py_ssize_tP.TO)
 view.c_internal = lltype.nullptr(rffi.VOIDP.TO)
 
diff --git a/pypy/module/cpyext/test/test_memoryobject.py 
b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -44,6 +44,7 @@
 ("fillinfo", "METH_VARARGS",
  """
  Py_buffer buf;
+ PyObject * ret = NULL;
  PyObject *str = PyBytes_FromString("hello, world.");
  if (PyBuffer_FillInfo(&buf, str, PyBytes_AsString(str), 13,
0, 0)) {
@@ -55,7 +56,14 @@
   */
  Py_DECREF(str);
 
- return PyMemoryView_FromBuffer(&buf);
+ ret = PyMemoryView_FromBuffer(&buf);
+ if (((PyMemoryViewObject*)ret)->view.obj != buf.obj)
+ {
+PyErr_SetString(PyExc_ValueError, "leaked ref");
+Py_DECREF(ret);
+return NULL;
+ }
+ return ret;
  """)])
 result = module.fillinfo()
 assert b"hello, world." == result
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy cpyext-FromBuffer: document a plan

2017-01-09 Thread mattip
Author: Matti Picus 
Branch: cpyext-FromBuffer
Changeset: r89456:b568c0a116df
Date: 2017-01-09 22:19 +0200
http://bitbucket.org/pypy/pypy/changeset/b568c0a116df/

Log:document a plan

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
@@ -214,6 +214,8 @@
 The memoryview object then owns the buffer, which means you shouldn't
 try to release it yourself: it will be released on deallocation of the
 memoryview object."""
+# XXX this should allocate a PyMemoryViewObject and
+# copy view into obj.c_view, without creating a new view.c_obj
 assert view.c_obj
 w_obj = from_ref(space, view.c_obj)
 if isinstance(w_obj, W_MemoryView):
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy api_func-refactor: Returning an ApiFunction object from _create_api_func() seems to make more sense

2017-01-09 Thread rlamy
Author: Ronan Lamy 
Branch: api_func-refactor
Changeset: r89457:1106b7b9f614
Date: 2017-01-09 20:31 +
http://bitbucket.org/pypy/pypy/changeset/1106b7b9f614/

Log:Returning an ApiFunction object from _create_api_func() seems to
make more sense

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
@@ -447,9 +447,12 @@
 else:
 c_name = func.__name__
 
-unwrapper = _create_api_func(
+api_function = _create_api_func(
 func, argtypes, restype, error, c_name, gil, result_borrowed,
 result_is_ll)
+unwrapper = api_function.get_unwrapper()
+unwrapper.func = func
+unwrapper.api_func = api_function
 
 # ZZZ is this whole logic really needed???  It seems to be only
 # for RPython code calling PyXxx() functions directly.  I would
@@ -473,7 +476,7 @@
 return res
 
 if header is not None:
-FUNCTIONS_BY_HEADER[header][func.__name__] = unwrapper.api_func
+FUNCTIONS_BY_HEADER[header][func.__name__] = api_function
 INTERPLEVEL_API[func.__name__] = unwrapper_catch  # used in tests
 return unwrapper
 return decorate
@@ -495,14 +498,9 @@
 error = rffi.cast(real_restype, error)
 
 func._always_inline_ = 'try'
-api_function = ApiFunction(argtypes, restype, func, error,
-c_name=c_name, gil=gil,
-result_borrowed=result_borrowed,
-result_is_ll=result_is_ll)
-unwrapper = api_function.get_unwrapper()
-unwrapper.func = func
-unwrapper.api_func = api_function
-return unwrapper
+return ApiFunction(
+argtypes, restype, func, error, c_name=c_name, gil=gil,
+result_borrowed=result_borrowed, result_is_ll=result_is_ll)
 
 
 def cpython_struct(name, fields, forward=None, level=1):
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy cpyext-FromBuffer: implement missing cpyext memoryobject pieces

2017-01-09 Thread mattip
Author: Matti Picus 
Branch: cpyext-FromBuffer
Changeset: r89458:8653ad15527c
Date: 2017-01-09 23:29 +0200
http://bitbucket.org/pypy/pypy/changeset/8653ad15527c/

Log:implement missing cpyext memoryobject pieces

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
@@ -3,7 +3,7 @@
  Py_ssize_tP, PyObjectFields, cpython_struct,
  bootstrap_function, Py_bufferP)
 from pypy.module.cpyext.pyobject import (PyObject, make_ref, as_pyobj, incref,
- decref, from_ref, make_typedescr)
+ decref, from_ref, make_typedescr, get_typedescr, track_reference)
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rlib.rarithmetic import widen
 from pypy.objspace.std.memoryobject import W_MemoryView
@@ -28,7 +28,7 @@
basestruct=PyMemoryViewObject.TO,
attach=memory_attach,
dealloc=memory_dealloc,
-   #realize=memory_realize,
+   realize=memory_realize,
   )
 
 def memory_attach(space, py_obj, w_obj, w_userdata=None):
@@ -54,11 +54,31 @@
  track_allocation=False))
 rffi.setintfield(view, 'c_readonly', 1)
 
-def memory_realize(space, py_obj):
+def memory_realize(space, obj):
 """
 Creates the memory object in the interpreter
 """
-raise oefmt(space.w_NotImplementedError, "cannot call this yet")
+from pypy.module.cpyext.slotdefs import CPyBuffer
+py_mem = rffi.cast(PyMemoryViewObject, obj)
+view = py_mem.c_view
+shape = None
+if view.c_shape:
+shape = [view.c_shape[i] for i in range(view.c_ndim)]
+strides = None
+if view.c_strides:
+strides = [view.c_strides[i] for i in range(view.c_ndim)]
+format = None
+if view.c_format:
+format = rffi.charp2str(view.c_format)
+buf = CPyBuffer(space, view.c_buf, view.c_len, from_ref(space, view.c_obj),
+format=format, shape=shape, strides=strides,
+ndim=view.c_ndim, itemsize=view.c_itemsize,
+readonly=view.c_readonly)
+w_type = from_ref(space, rffi.cast(PyObject, obj.c_ob_type))
+w_obj = space.allocate_instance(W_MemoryView, w_type)
+w_obj.__init__(buf)
+track_reference(space, obj, w_obj)
+return w_obj
 
 @cpython_api([PyObject], lltype.Void, header=None)
 def memory_dealloc(space, py_obj):
@@ -208,7 +228,7 @@
 py_memview = make_ref(space, w_memview, w_obj)
 return py_memview
 
-@cpython_api([Py_bufferP], PyObject)
+@cpython_api([Py_bufferP], PyObject, result_is_ll=True)
 def PyMemoryView_FromBuffer(space, view):
 """Create a memoryview object wrapping the given buffer-info structure 
view.
 The memoryview object then owns the buffer, which means you shouldn't
@@ -216,11 +236,27 @@
 memoryview object."""
 # XXX this should allocate a PyMemoryViewObject and
 # copy view into obj.c_view, without creating a new view.c_obj
-assert view.c_obj
-w_obj = from_ref(space, view.c_obj)
-if isinstance(w_obj, W_MemoryView):
-return w_obj
-return space.call_method(space.builtin, "memoryview", w_obj)
+typedescr = get_typedescr(W_MemoryView.typedef)
+py_obj = typedescr.allocate(space, space.w_memoryview)
+py_mem = rffi.cast(PyMemoryViewObject, py_obj)
+for f in ('c_buf', 'c_obj', 'c_len', 'c_itemsize', 'c_readonly', 'c_ndim', 
'c_format'):
+setattr(py_mem.c_view, f, getattr(view, f))
+if view.c_strides == rffi.cast(Py_ssize_tP, view.c__strides):
+py_mem.c_view.c_strides = rffi.cast(Py_ssize_tP, 
py_mem.c_view.c__strides)
+for i in range(view.c_ndim):
+py_mem.c_view.c_strides[i] = view.c_strides[i]
+else:
+# some externally allocated memory chunk
+py_mem.c_view.c_strides = view.c_strides
+if view.c_shape == rffi.cast(Py_ssize_tP, view.c__shape):
+py_mem.c_view.c_shape = rffi.cast(Py_ssize_tP, py_mem.c_view.c__shape)
+for i in range(view.c_ndim):
+py_mem.c_view.c_shape[i] = view.c_shape[i]
+else:
+# some externally allocated memory chunk
+py_mem.c_view.c_shape = view.c_shape
+# XXX ignore suboffsets?
+return py_obj
 
 @cpython_api([PyObject], PyObject)
 def PyMemoryView_GET_BASE(space, w_obj):
diff --git a/pypy/module/cpyext/test/test_memoryobject.py 
b/pypy/module/cpyext/test/test_memoryobject.py
--- a/pypy/module/cpyext/test/test_memoryobject.py
+++ b/pypy/module/cpyext/test/test_memoryobject.py
@@ -30,7 +30,7 @@
 assert view.c_len == 5
 o = rffi.charp2str(view.c_buf)
 assert o == 'hello'
-w_mv = api.PyMemoryView_FromBuffer(view)
+w_mv = from_ref(space, api.PyMemoryView_FromBuffer(view))
 for f in ('format', 'itemsize', 'ndim', 'readonly', 
   'shape

[pypy-commit] pypy api_func-refactor: Split off header=None case from @cpython_api into new decorator @slot_function

2017-01-09 Thread rlamy
Author: Ronan Lamy 
Branch: api_func-refactor
Changeset: r89459:9a171817ba6d
Date: 2017-01-10 02:09 +
http://bitbucket.org/pypy/pypy/changeset/9a171817ba6d/

Log:Split off header=None case from @cpython_api into new decorator
@slot_function

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
@@ -427,29 +427,17 @@
   special value 'CANNOT_FAIL' (also when restype is Void) turns an eventual
   exception into a wrapped SystemError.  Unwrapped exceptions also cause a
   SytemError.
-- `header` is the header file to export the function in, Set to None to get
-  a C function pointer, but not exported by the API headers.
+- `header` is the header file to export the function in.
 - set `gil` to "acquire", "release" or "around" to acquire the GIL,
   release the GIL, or both
 """
-if isinstance(restype, lltype.Typedef):
-real_restype = restype.OF
-else:
-real_restype = restype
-expect_integer = (isinstance(real_restype, lltype.Primitive) and
-  rffi.cast(restype, 0) == 0)
+assert header is not None
 def decorate(func):
-if header is not None:
-if func.__name__ in FUNCTIONS_BY_HEADER[header]:
-raise ValueError("%s already registered" % func.__name__)
-if header is not None:
-c_name = None
-else:
-c_name = func.__name__
-
+if func.__name__ in FUNCTIONS_BY_HEADER[header]:
+raise ValueError("%s already registered" % func.__name__)
 api_function = _create_api_func(
-func, argtypes, restype, error, c_name, gil, result_borrowed,
-result_is_ll)
+func, argtypes, restype, error, gil=gil,
+result_borrowed=result_borrowed, result_is_ll=result_is_ll)
 unwrapper = api_function.get_unwrapper()
 unwrapper.func = func
 unwrapper.api_func = api_function
@@ -471,6 +459,12 @@
 else:
 return unwrapper.api_func.error_value
 got_integer = isinstance(res, (int, long, float))
+if isinstance(restype, lltype.Typedef):
+real_restype = restype.OF
+else:
+real_restype = restype
+expect_integer = (isinstance(real_restype, lltype.Primitive) and
+rffi.cast(restype, 0) == 0)
 assert got_integer == expect_integer, (
 'got %r not integer' % (res,))
 return res
@@ -481,6 +475,17 @@
 return unwrapper
 return decorate
 
+def slot_function(argtypes, restype, error=_NOT_SPECIFIED):
+def decorate(func):
+c_name = func.__name__
+api_function = _create_api_func(func, argtypes, restype, error, c_name)
+unwrapper = api_function.get_unwrapper()
+unwrapper.func = func
+unwrapper.api_func = api_function
+return unwrapper
+return decorate
+
+
 def _create_api_func(
 func, argtypes, restype, error=_NOT_SPECIFIED, c_name=None,
 gil=None, result_borrowed=False, result_is_ll=False):
diff --git a/pypy/module/cpyext/bufferobject.py 
b/pypy/module/cpyext/bufferobject.py
--- a/pypy/module/cpyext/bufferobject.py
+++ b/pypy/module/cpyext/bufferobject.py
@@ -2,7 +2,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from pypy.interpreter.error import oefmt
 from pypy.module.cpyext.api import (
-cpython_api, Py_ssize_t, cpython_struct, bootstrap_function,
+cpython_api, Py_ssize_t, cpython_struct, bootstrap_function, slot_function,
 PyObjectFields, PyObject)
 from pypy.module.cpyext.pyobject import make_typedescr, Py_DecRef, make_ref
 from pypy.module.array.interp_array import ArrayBuffer
@@ -72,7 +72,7 @@
 "Don't know how to realize a buffer")
 
 
-@cpython_api([PyObject], lltype.Void, header=None)
+@slot_function([PyObject], lltype.Void)
 def buffer_dealloc(space, py_obj):
 py_buf = rffi.cast(PyBufferObject, py_obj)
 if py_buf.c_b_base:
diff --git a/pypy/module/cpyext/bytesobject.py 
b/pypy/module/cpyext/bytesobject.py
--- a/pypy/module/cpyext/bytesobject.py
+++ b/pypy/module/cpyext/bytesobject.py
@@ -2,7 +2,7 @@
 from rpython.rtyper.lltypesystem import rffi, lltype
 from pypy.module.cpyext.api import (
 cpython_api, cpython_struct, bootstrap_function, build_type_checkers,
-PyVarObjectFields, Py_ssize_t, CONST_STRING, CANNOT_FAIL)
+PyVarObjectFields, Py_ssize_t, CONST_STRING, CANNOT_FAIL, slot_function)
 from pypy.module.cpyext.pyerrors import PyErr_BadArgument
 from pypy.module.cpyext.pyobject import (
 PyObject, PyObjectP, Py_DecRef, make_ref, from_ref, track_reference,
@@ -25,14 +25,14 @@
 ##
 ## In the PyBytesObject returned, the ob_sval buffer may be modified as
 ## long as the freshly allocated PyBytesObject is not "forced" via a call
-## to any of the more sophisticated C-API functions. 
+

[pypy-commit] pypy cpyext-FromBuffer: name clarification, translation fixes

2017-01-09 Thread mattip
Author: Matti Picus 
Branch: cpyext-FromBuffer
Changeset: r89460:69a5e99dcc8e
Date: 2017-01-10 08:45 +0200
http://bitbucket.org/pypy/pypy/changeset/69a5e99dcc8e/

Log:name clarification, translation fixes

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
@@ -58,7 +58,7 @@
 """
 Creates the memory object in the interpreter
 """
-from pypy.module.cpyext.slotdefs import CPyBuffer
+from pypy.module.cpyext.slotdefs import CPyBuffer, fq
 py_mem = rffi.cast(PyMemoryViewObject, obj)
 view = py_mem.c_view
 shape = None
@@ -67,13 +67,16 @@
 strides = None
 if view.c_strides:
 strides = [view.c_strides[i] for i in range(view.c_ndim)]
-format = None
+format = 'B'
 if view.c_format:
 format = rffi.charp2str(view.c_format)
 buf = CPyBuffer(space, view.c_buf, view.c_len, from_ref(space, view.c_obj),
 format=format, shape=shape, strides=strides,
 ndim=view.c_ndim, itemsize=view.c_itemsize,
 readonly=view.c_readonly)
+# Ensure view.c_buf is released upon object finalization
+fq.register_finalizer(buf)
+# Allow subclassing W_MemeoryView
 w_type = from_ref(space, rffi.cast(PyObject, obj.c_ob_type))
 w_obj = space.allocate_instance(W_MemoryView, w_type)
 w_obj.__init__(buf)
@@ -239,8 +242,14 @@
 typedescr = get_typedescr(W_MemoryView.typedef)
 py_obj = typedescr.allocate(space, space.w_memoryview)
 py_mem = rffi.cast(PyMemoryViewObject, py_obj)
-for f in ('c_buf', 'c_obj', 'c_len', 'c_itemsize', 'c_readonly', 'c_ndim', 
'c_format'):
-setattr(py_mem.c_view, f, getattr(view, f))
+mview = py_mem.c_view
+mview.c_buf = view.c_buf
+mview.c_obj = view.c_obj
+mview.c_len = view.c_len
+mview.c_itemsize = view.c_itemsize
+mview.c_readonly = view.c_readonly
+mview.c_ndim = view.c_ndim
+mview.c_format = view.c_format
 if view.c_strides == rffi.cast(Py_ssize_tP, view.c__strides):
 py_mem.c_view.c_strides = rffi.cast(Py_ssize_tP, 
py_mem.c_view.c__strides)
 for i in range(view.c_ndim):
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
@@ -324,7 +324,7 @@
 
 def __init__(self, space, ptr, size, w_obj, format='B', shape=None,
 strides=None, ndim=1, itemsize=1, readonly=True,
-releasebuffer=None):
+releasebufferproc=rffi.cast(rffi.VOIDP, 0)):
 self.space = space
 self.ptr = ptr
 self.size = size
@@ -342,7 +342,7 @@
 self.ndim = ndim
 self.itemsize = itemsize
 self.readonly = readonly
-self.releasebufferproc = releasebuffer
+self.releasebufferproc = releasebufferproc
 
 def releasebuffer(self):
 if self.pyobj:
@@ -360,7 +360,10 @@
 for i in range(self.ndim):
 pybuf.c_shape[i] = self.shape[i]
 pybuf.c_strides[i] = self.strides[i]
-pybuf.c_format = rffi.str2charp(self.format)
+if self.format:
+pybuf.c_format = rffi.str2charp(self.format)
+else:
+pybuf.c_format = rffi.str2charp("B")
 generic_cpy_call(self.space, func_target, self.pyobj, pybuf)
 self.releasebufferproc = rffi.cast(rffi.VOIDP, 0)
 
@@ -407,9 +410,9 @@
 func_target = rffi.cast(readbufferproc, func)
 py_obj = make_ref(space, w_self)
 py_type = py_obj.c_ob_type
-releasebuffer = rffi.cast(rffi.VOIDP, 0)
+rbp = rffi.cast(rffi.VOIDP, 0)
 if py_type.c_tp_as_buffer:
-releasebuffer = rffi.cast(rffi.VOIDP, 
py_type.c_tp_as_buffer.c_bf_releasebuffer)
+rbp = rffi.cast(rffi.VOIDP, py_type.c_tp_as_buffer.c_bf_releasebuffer)
 decref(space, py_obj)
 with lltype.scoped_alloc(rffi.VOIDPP.TO, 1) as ptr:
 index = rffi.cast(Py_ssize_t, 0)
@@ -417,7 +420,7 @@
 if size < 0:
 space.fromcache(State).check_and_raise_exception(always=True)
 buf = CPyBuffer(space, ptr[0], size, w_self,
-   releasebuffer=releasebuffer)
+   releasebufferproc=rbp)
 fq.register_finalizer(buf)
 return space.newbuffer(buf)
 
@@ -426,16 +429,16 @@
 py_obj = make_ref(space, w_self)
 py_type = py_obj.c_ob_type
 decref(space, py_obj)
-releasebuffer = rffi.cast(rffi.VOIDP, 0)
+rbp = rffi.cast(rffi.VOIDP, 0)
 if py_type.c_tp_as_buffer:
-releasebuffer = rffi.cast(rffi.VOIDP, 
py_type.c_tp_as_buffer.c_bf_releasebuffer)
+rbp = rffi.cast(rffi.VOIDP, py_type.c_tp_as_buffer.c_bf_releasebuffer)
 with lltype.scoped_alloc(rffi.VOIDPP.TO, 1) as ptr:
 index = rffi.cast(Py_ssize_t, 0)
 size = gene

[pypy-commit] pypy py3.5: fix

2017-01-09 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r89461:ecb699d457d3
Date: 2017-01-10 08:42 +0100
http://bitbucket.org/pypy/pypy/changeset/ecb699d457d3/

Log:fix

diff --git a/pypy/module/unicodedata/__init__.py 
b/pypy/module/unicodedata/__init__.py
--- a/pypy/module/unicodedata/__init__.py
+++ b/pypy/module/unicodedata/__init__.py
@@ -14,7 +14,7 @@
 interpleveldefs = {
 'unidata_version' : 'space.wrap(interp_ucd.ucd.version)',
 'ucd_3_2_0'   : 'space.wrap(interp_ucd.ucd_3_2_0)',
-'ucd_6_1_0'   : 'space.wrap(interp_ucd.ucd_6_1_0)',
+'ucd_8_0_0'   : 'space.wrap(interp_ucd.ucd_8_0_0)',
 'ucd' : 'space.wrap(interp_ucd.ucd)',
 '__doc__' : "space.wrap('unicode character database')",
 }
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit