[pypy-commit] pypy py3.5: skip test on pypy
Author: Armin Rigo Branch: py3.5 Changeset: r89607:7c74a79913f5 Date: 2017-01-16 10:09 +0100 http://bitbucket.org/pypy/pypy/changeset/7c74a79913f5/ Log:skip test on pypy diff --git a/lib-python/3/test/test_logging.py b/lib-python/3/test/test_logging.py --- a/lib-python/3/test/test_logging.py +++ b/lib-python/3/test/test_logging.py @@ -3407,6 +3407,7 @@ logging.setLoggerClass(logging.Logger) self.assertEqual(logging.getLoggerClass(), logging.Logger) [email protected]_only# PyPy doesn't call __del__() at shutdown def test_logging_at_shutdown(self): # Issue #20037 code = """if 1: ___ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy rffi-parser-2: Rename ParsedSource to CTypeSpace
Author: Ronan Lamy
Branch: rffi-parser-2
Changeset: r89608:edc637d97ac6
Date: 2017-01-16 14:56 +
http://bitbucket.org/pypy/pypy/changeset/edc637d97ac6/
Log:Rename ParsedSource to CTypeSpace
diff --git a/pypy/module/cpyext/cparser.py b/pypy/module/cpyext/cparser.py
--- a/pypy/module/cpyext/cparser.py
+++ b/pypy/module/cpyext/cparser.py
@@ -684,9 +684,8 @@
return "".format(**vars(self))
-class ParsedSource(object):
+class CTypeSpace(object):
def __init__(self, source, parser, definitions=None, macros=None,
headers=None):
-from pypy.module.cpyext.api import configure_eci
self.source = source
self.definitions = definitions if definitions is not None else {}
self.macros = macros if macros is not None else {}
@@ -823,7 +822,7 @@
def parse_source(source, includes=None, headers=None, configure_now=True):
ctx = Parser()
-src = ParsedSource(source, ctx, headers=headers)
+src = CTypeSpace(source, ctx, headers=headers)
if includes is not None:
for header in includes:
src.include(header)
diff --git a/pypy/module/cpyext/test/test_cparser.py
b/pypy/module/cpyext/test/test_cparser.py
--- a/pypy/module/cpyext/test/test_cparser.py
+++ b/pypy/module/cpyext/test/test_cparser.py
@@ -11,8 +11,8 @@
double ob_fval;
} TestFloatObject;
"""
-res = parse_source(decl)
-TestFloatObject = res.definitions['TestFloatObject']
+cts = parse_source(decl)
+TestFloatObject = cts.definitions['TestFloatObject']
assert isinstance(TestFloatObject, lltype.Struct)
assert TestFloatObject.c_ob_refcnt == rffi.SSIZE_T
assert TestFloatObject.c_ob_pypy_link == rffi.SSIZE_T
@@ -20,8 +20,8 @@
def test_simple():
decl = "typedef ssize_t Py_ssize_t;"
-hdr = parse_source(decl)
-assert hdr.definitions == {'Py_ssize_t': rffi.SSIZE_T}
+cts = parse_source(decl)
+assert cts.definitions == {'Py_ssize_t': rffi.SSIZE_T}
def test_macro():
decl = """
@@ -36,9 +36,9 @@
double ob_fval;
} PyFloatObject;
"""
-hdr = parse_source(decl)
-assert 'PyFloatObject' in hdr.definitions
-assert 'PyObject_HEAD' in hdr.macros
+cts = parse_source(decl)
+assert 'PyFloatObject' in cts.definitions
+assert 'PyObject_HEAD' in cts.macros
def test_include():
cdef1 = """
@@ -59,12 +59,12 @@
Type *type;
} Object;
"""
-hdr1 = parse_source(cdef1)
-Type = hdr1.definitions['Type']
+cts1 = parse_source(cdef1)
+Type = cts1.definitions['Type']
assert isinstance(Type, lltype.Struct)
-hdr2 = parse_source(cdef2, includes=[hdr1])
-assert 'Type' not in hdr2.definitions
-Object = hdr2.definitions['Object']
+cts2 = parse_source(cdef2, includes=[cts1])
+assert 'Type' not in cts2.definitions
+Object = cts2.definitions['Object']
assert Object.c_type.TO is Type
def test_incomplete():
@@ -83,8 +83,8 @@
} Buffer;
"""
-foo_h = parse_source(cdef)
-Object = foo_h.gettype('Object')
+cts = parse_source(cdef)
+Object = cts.gettype('Object')
assert isinstance(Object, lltype.Struct)
def test_recursive():
@@ -106,8 +106,8 @@
Object *obj;
} Type;
"""
-foo_h = parse_source(cdef)
-Object = foo_h.definitions['Object']
+cts = parse_source(cdef)
+Object = cts.definitions['Object']
assert isinstance(Object, lltype.Struct)
hash(Object)
@@ -117,8 +117,8 @@
const char * const foo;
} bar;
"""
-hdr = parse_source(cdef)
-assert hdr.definitions['bar'].c_foo == rffi.CONST_CCHARP != rffi.CCHARP
+cts = parse_source(cdef)
+assert cts.definitions['bar'].c_foo == rffi.CONST_CCHARP != rffi.CCHARP
def test_gettype():
decl = """
@@ -133,9 +133,9 @@
double ob_fval;
} TestFloatObject;
"""
-res = parse_source(decl)
-assert res.gettype('Py_ssize_t') == rffi.SSIZE_T
-assert res.gettype('TestFloatObject *').TO.c_ob_refcnt == rffi.SSIZE_T
+cts = parse_source(decl)
+assert cts.gettype('Py_ssize_t') == rffi.SSIZE_T
+assert cts.gettype('TestFloatObject *').TO.c_ob_refcnt == rffi.SSIZE_T
def test_parse_funcdecl():
decl = """
@@ -152,8 +152,8 @@
typedef TestFloatObject* (*func_t)(int, int);
"""
-res = parse_source(decl)
-name, FUNC = res.parse_func("func_t some_func(TestFloatObject*)")
+cts = parse_source(decl)
+name, FUNC = cts.parse_func("func_t some_func(TestFloatObject*)")
assert name == 'some_func'
-assert FUNC.RESULT == res.gettype('func_t')
-assert FUNC.ARGS == (res.gettype('TestFloatObject *'),)
+assert FUNC.RESULT == cts.gettype('func_t')
+assert FUNC.ARGS == (cts.gettype('TestFloatObject *'),)
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy rffi-parser-2: Move some logic from parse_source to CTypeSpace.__init__
Author: Ronan Lamy
Branch: rffi-parser-2
Changeset: r89609:f2837cdef16e
Date: 2017-01-16 15:18 +
http://bitbucket.org/pypy/pypy/changeset/f2837cdef16e/
Log:Move some logic from parse_source to CTypeSpace.__init__
diff --git a/pypy/module/cpyext/cparser.py b/pypy/module/cpyext/cparser.py
--- a/pypy/module/cpyext/cparser.py
+++ b/pypy/module/cpyext/cparser.py
@@ -685,17 +685,21 @@
class CTypeSpace(object):
-def __init__(self, source, parser, definitions=None, macros=None,
headers=None):
+def __init__(self, source, parser=None, definitions=None, macros=None,
+ headers=None, includes=None):
self.source = source
self.definitions = definitions if definitions is not None else {}
self.macros = macros if macros is not None else {}
self.structs = {}
-self.ctx = parser
+self.ctx = parser if parser else Parser()
self.headers = headers if headers is not None else ['sys/types.h']
self._Config = type('Config', (object,), {})
self._TYPES = {}
self.includes = []
self.struct_typedefs = {}
+if includes is not None:
+for header in includes:
+self.include(header)
def include(self, other):
self.ctx.include(other.ctx)
@@ -821,11 +825,7 @@
def parse_source(source, includes=None, headers=None, configure_now=True):
-ctx = Parser()
-src = CTypeSpace(source, ctx, headers=headers)
-if includes is not None:
-for header in includes:
-src.include(header)
-ctx.parse(source)
+src = CTypeSpace(source, headers=headers, includes=includes)
+src.ctx.parse(source)
src.configure_types()
return src
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Fix the __repr__ of bound methods to use the qualname of the function
Author: Armin Rigo
Branch: py3.5
Changeset: r89610:babebbeb4488
Date: 2017-01-16 17:45 +0100
http://bitbucket.org/pypy/pypy/changeset/babebbeb4488/
Log:Fix the __repr__ of bound methods to use the qualname of the
function
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -535,11 +535,18 @@
def descr_method_repr(self):
space = self.space
-name = self.w_function.getname(self.space)
-w_class = space.type(self.w_instance)
-typename = w_class.getname(self.space)
+w_name = space.findattr(self.w_function, space.wrap('__qualname__'))
+if w_name is None:
+name = self.w_function.getname(self.space)
+else:
+try:
+name = space.unicode_w(w_name)
+except OperationError as e:
+if not e.match(space, space.w_TypeError):
+raise
+name = '?'
objrepr = space.unicode_w(space.repr(self.w_instance))
-s = u'' % (typename, name, objrepr)
+s = u'' % (name, objrepr)
return space.wrap(s)
def descr_method_getattribute(self, w_attr):
diff --git a/pypy/interpreter/test/test_function.py
b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -516,14 +516,19 @@
class A(object):
def f(self):
pass
-assert repr(A().f).startswith(">")
-class B:
+
+def test_method_repr_2(self):
+class ClsA(object):
def f(self):
pass
-assert repr(B().f).startswith(">")
-
+class ClsB(ClsA):
+pass
+r = repr(ClsB().f)
+assert "ClsA.f of <" in r
+assert "ClsB object at " in r
def test_method_call(self):
class C(object):
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy missing-tp_new: typo (rlamy)
Author: Matti Picus Branch: missing-tp_new Changeset: r89611:e5365fbac53f Date: 2017-01-16 19:07 +0200 http://bitbucket.org/pypy/pypy/changeset/e5365fbac53f/ Log:typo (rlamy) 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 @@ -1126,7 +1126,7 @@ setup_init_functions(eci, prefix) return modulename.new(ext='') -def attach_recusively(space, static_pyobjs, static_objs_w, attached_objs, i): +def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): # Start at i but make sure all the base classes are already attached from pypy.module.cpyext.pyobject import get_typedescr, make_ref if i in attached_objs: @@ -1145,7 +1145,7 @@ except ValueError: j = -1 if j >=0 and j not in attached_objs: -attach_recusively(space, static_pyobjs, static_objs_w, +attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, j) w_type = space.type(w_obj) typedescr = get_typedescr(w_type.layout.typedef) @@ -1185,7 +1185,7 @@ self.cpyext_type_init = [] attached_objs = [] for i in range(len(static_objs_w)): -attach_recusively(space, static_pyobjs, static_objs_w, attached_objs, i) +attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) cpyext_type_init = self.cpyext_type_init self.cpyext_type_init = None for pto, w_type in cpyext_type_init: ___ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy rffi-parser-2: Allow parsing multiple headers into the same cts
Author: Ronan Lamy
Branch: rffi-parser-2
Changeset: r89612:ce1401635012
Date: 2017-01-16 17:04 +
http://bitbucket.org/pypy/pypy/changeset/ce1401635012/
Log:Allow parsing multiple headers into the same cts
diff --git a/pypy/module/cpyext/cparser.py b/pypy/module/cpyext/cparser.py
--- a/pypy/module/cpyext/cparser.py
+++ b/pypy/module/cpyext/cparser.py
@@ -685,9 +685,9 @@
class CTypeSpace(object):
-def __init__(self, source, parser=None, definitions=None, macros=None,
+def __init__(self, parser=None, definitions=None, macros=None,
headers=None, includes=None):
-self.source = source
+self.sources = []
self.definitions = definitions if definitions is not None else {}
self.macros = macros if macros is not None else {}
self.structs = {}
@@ -697,6 +697,7 @@
self._TYPES = {}
self.includes = []
self.struct_typedefs = {}
+self._handled = set()
if includes is not None:
for header in includes:
self.include(header)
@@ -706,6 +707,11 @@
self.structs.update(other.structs)
self.includes.append(other)
+def parse_source(self, source):
+self.sources.append(source)
+self.ctx.parse(source)
+self.configure_types()
+
def add_typedef(self, name, obj, quals):
assert name not in self.definitions
tp = self.convert_type(obj, quals)
@@ -746,7 +752,10 @@
return struct.TYPE
def build_eci(self):
-all_sources = [x.source for x in self.includes] + [self.source]
+all_sources = []
+for cts in self.includes:
+all_sources.extend(cts.sources)
+all_sources.extend(self.sources)
all_headers = self.headers
for x in self.includes:
for hdr in x.headers:
@@ -759,6 +768,9 @@
for name, (obj, quals) in self.ctx._declarations.iteritems():
if obj in self.ctx._included_declarations:
continue
+if name in self._handled:
+continue
+self._handled.add(name)
if name.startswith('typedef '):
name = name[8:]
self.add_typedef(name, obj, quals)
@@ -771,6 +783,7 @@
del TYPE._hints['eci']
if name in self._TYPES:
self._TYPES[name].become(TYPE)
+del self._TYPES[name]
def convert_type(self, obj, quals=0):
if isinstance(obj, model.PrimitiveType):
@@ -825,7 +838,6 @@
def parse_source(source, includes=None, headers=None, configure_now=True):
-src = CTypeSpace(source, headers=headers, includes=includes)
-src.ctx.parse(source)
-src.configure_types()
-return src
+cts = CTypeSpace(headers=headers, includes=includes)
+cts.parse_source(source)
+return cts
diff --git a/pypy/module/cpyext/test/test_cparser.py
b/pypy/module/cpyext/test/test_cparser.py
--- a/pypy/module/cpyext/test/test_cparser.py
+++ b/pypy/module/cpyext/test/test_cparser.py
@@ -1,5 +1,5 @@
from rpython.rtyper.lltypesystem import rffi, lltype
-from pypy.module.cpyext.cparser import parse_source
+from pypy.module.cpyext.cparser import parse_source, CTypeSpace
def test_configure():
decl = """
@@ -67,6 +67,34 @@
Object = cts2.definitions['Object']
assert Object.c_type.TO is Type
+def test_multiple_sources():
+cdef1 = """
+typedef ssize_t Py_ssize_t;
+
+#define PyObject_HEAD \
+Py_ssize_t ob_refcnt;\
+Py_ssize_t ob_pypy_link; \
+
+typedef struct {
+char *name;
+} Type;
+"""
+cdef2 = """
+typedef struct {
+PyObject_HEAD
+Py_ssize_t ob_foo;
+Type *type;
+} Object;
+"""
+cts = CTypeSpace()
+cts.parse_source(cdef1)
+Type = cts.definitions['Type']
+assert isinstance(Type, lltype.Struct)
+assert 'Object' not in cts.definitions
+cts.parse_source(cdef2)
+Object = cts.definitions['Object']
+assert Object.c_type.TO is Type
+
def test_incomplete():
cdef = """
typedef ssize_t Py_ssize_t;
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy rffi-parser-2: Use only one cts for all of cpyext
Author: Ronan Lamy
Branch: rffi-parser-2
Changeset: r89613:d218f1328c08
Date: 2017-01-16 17:28 +
http://bitbucket.org/pypy/pypy/changeset/d218f1328c08/
Log:Use only one cts for all of cpyext
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
@@ -40,7 +40,7 @@
from rpython.rlib import rawrefcount
from rpython.rlib import rthread
from rpython.rlib.debug import fatalerror_notb
-from pypy.module.cpyext.cparser import parse_source
+from pypy.module.cpyext.cparser import CTypeSpace
DEBUG_WRAPPER = True
@@ -671,30 +671,30 @@
build_exported_objects()
object_cdef = (parse_dir / 'cpyext_object.h').read()
-object_h = parse_source(object_cdef,
-headers=['sys/types.h', 'stdarg.h', 'stdio.h'])
+cts = CTypeSpace(headers=['sys/types.h', 'stdarg.h', 'stdio.h'])
+cts.parse_source(object_cdef)
-Py_ssize_t = object_h.gettype('Py_ssize_t')
-Py_ssize_tP = object_h.gettype('Py_ssize_t *')
+Py_ssize_t = cts.gettype('Py_ssize_t')
+Py_ssize_tP = cts.gettype('Py_ssize_t *')
size_t = rffi.ULONG
ADDR = lltype.Signed
# Note: as a special case, "PyObject" is the pointer type in RPython,
# corresponding to "PyObject *" in C. We do that only for PyObject.
# For example, "PyTypeObject" is the struct type even in RPython.
-PyTypeObject = object_h.gettype('PyTypeObject')
-PyTypeObjectPtr = object_h.gettype('PyTypeObject *')
-PyObjectStruct = object_h.gettype('PyObject')
-PyObject = object_h.gettype('PyObject *')
+PyTypeObject = cts.gettype('PyTypeObject')
+PyTypeObjectPtr = cts.gettype('PyTypeObject *')
+PyObjectStruct = cts.gettype('PyObject')
+PyObject = cts.gettype('PyObject *')
PyObjectFields = (("ob_refcnt", lltype.Signed),
("ob_pypy_link", lltype.Signed),
("ob_type", PyTypeObjectPtr))
PyVarObjectFields = PyObjectFields + (("ob_size", Py_ssize_t), )
-PyVarObjectStruct = object_h.gettype('PyVarObject')
-PyVarObject = object_h.gettype('PyVarObject *')
+PyVarObjectStruct = cts.gettype('PyVarObject')
+PyVarObject = cts.gettype('PyVarObject *')
-Py_buffer = object_h.gettype('Py_buffer')
-Py_bufferP = object_h.gettype('Py_buffer *')
+Py_buffer = cts.gettype('Py_buffer')
+Py_bufferP = cts.gettype('Py_buffer *')
@specialize.memo()
diff --git a/pypy/module/cpyext/methodobject.py
b/pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py
+++ b/pypy/module/cpyext/methodobject.py
@@ -11,13 +11,13 @@
CONST_STRING, METH_CLASS, METH_COEXIST, METH_KEYWORDS, METH_NOARGS, METH_O,
METH_STATIC, METH_VARARGS, PyObject, PyObjectFields, bootstrap_function,
build_type_checkers, cpython_api, cpython_struct, generic_cpy_call,
-PyTypeObjectPtr, slot_function, object_h, api_decl)
+PyTypeObjectPtr, slot_function, cts, api_decl)
from pypy.module.cpyext.pyobject import (
Py_DecRef, from_ref, make_ref, as_pyobj, make_typedescr)
-PyMethodDef = object_h.gettype('PyMethodDef')
-PyCFunction = object_h.gettype('PyCFunction')
-PyCFunctionKwArgs = object_h.gettype('PyCFunctionWithKeywords')
+PyMethodDef = cts.gettype('PyMethodDef')
+PyCFunction = cts.gettype('PyCFunction')
+PyCFunctionKwArgs = cts.gettype('PyCFunctionWithKeywords')
PyCFunctionObjectStruct = cpython_struct(
'PyCFunctionObject',
PyObjectFields + (
@@ -282,7 +282,7 @@
def PyCFunction_NewEx(space, ml, w_self, w_name):
return space.wrap(W_PyCFunctionObject(space, ml, w_self, w_name))
-@api_decl("PyCFunction PyCFunction_GetFunction(PyObject *)", object_h)
+@api_decl("PyCFunction PyCFunction_GetFunction(PyObject *)", cts)
def PyCFunction_GetFunction(space, w_obj):
try:
cfunction = space.interp_w(W_PyCFunctionObject, w_obj)
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
@@ -17,7 +17,7 @@
Py_TPFLAGS_HAVE_GETCHARBUFFER, build_type_checkers,
PyObjectFields, PyTypeObject, PyTypeObjectPtr,
Py_TPFLAGS_HAVE_NEWBUFFER, Py_TPFLAGS_CHECKTYPES,
-Py_TPFLAGS_HAVE_INPLACEOPS, object_h, parse_dir)
+Py_TPFLAGS_HAVE_INPLACEOPS, cts, parse_dir)
from pypy.module.cpyext.cparser import parse_source
from pypy.module.cpyext.methodobject import (W_PyCClassMethodObject,
W_PyCWrapperObject, PyCFunction_NewEx, PyCFunction, PyMethodDef,
@@ -42,9 +42,9 @@
PyType_Check, PyType_CheckExact = build_type_checkers("Type", "w_type")
cdef = (parse_dir / 'cpyext_typeobject.h').read()
-typeobject_h = parse_source(cdef, includes=[object_h])
-PyHeapTypeObjectStruct = typeobject_h.gettype('PyHeapTypeObject')
-PyHeapTypeObject = typeobject_h.gettype('PyHeapTypeObject *')
+cts.parse_source(cdef)
+PyHeapTypeObjectStruct = cts.gettype('PyHeapTypeObject')
+PyHeapTypeObject = cts.gettype('PyHeapTypeObject *')
class W_GetSetPropertyEx(GetSetProperty):
diff --git a/pypy/module/cpyext/typeobjectdefs.py
b/pypy/module/cpyext/typeobjectdefs.py
--- a/pypy/module/cpyext/typeobj
[pypy-commit] pypy rffi-parser-2: Add CTypeSpace.parse_header()
Author: Ronan Lamy
Branch: rffi-parser-2
Changeset: r89614:47602e2d9f0e
Date: 2017-01-16 18:14 +
http://bitbucket.org/pypy/pypy/changeset/47602e2d9f0e/
Log:Add CTypeSpace.parse_header()
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
@@ -142,14 +142,14 @@
target.chmod(0444) # make the file read-only, to make sure that nobody
# edits it by mistake
-def copy_header_files(dstdir, copy_numpy_headers):
+def copy_header_files(cts, dstdir, copy_numpy_headers):
# XXX: 20 lines of code to recursively copy a directory, really??
assert dstdir.check(dir=True)
headers = include_dir.listdir('*.h') + include_dir.listdir('*.inl')
for name in ["pypy_macros.h"] + FUNCTIONS_BY_HEADER.keys():
headers.append(udir.join(name))
-headers.append(parse_dir / 'cpyext_object.h')
-headers.append(parse_dir / 'cpyext_typeobject.h')
+for path in cts.parsed_headers:
+headers.append(path)
_copy_header_files(headers, dstdir)
if copy_numpy_headers:
@@ -670,9 +670,8 @@
% (cpyname, ))
build_exported_objects()
-object_cdef = (parse_dir / 'cpyext_object.h').read()
cts = CTypeSpace(headers=['sys/types.h', 'stdarg.h', 'stdio.h'])
-cts.parse_source(object_cdef)
+cts.parse_header(parse_dir / 'cpyext_object.h')
Py_ssize_t = cts.gettype('Py_ssize_t')
Py_ssize_tP = cts.gettype('Py_ssize_t *')
@@ -1410,7 +1409,7 @@
setup_init_functions(eci, prefix)
trunk_include = pypydir.dirpath() / 'include'
-copy_header_files(trunk_include, use_micronumpy)
+copy_header_files(cts, trunk_include, use_micronumpy)
def _load_from_cffi(space, name, path, initptr):
diff --git a/pypy/module/cpyext/cparser.py b/pypy/module/cpyext/cparser.py
--- a/pypy/module/cpyext/cparser.py
+++ b/pypy/module/cpyext/cparser.py
@@ -687,12 +687,13 @@
class CTypeSpace(object):
def __init__(self, parser=None, definitions=None, macros=None,
headers=None, includes=None):
-self.sources = []
self.definitions = definitions if definitions is not None else {}
self.macros = macros if macros is not None else {}
self.structs = {}
self.ctx = parser if parser else Parser()
self.headers = headers if headers is not None else ['sys/types.h']
+self.parsed_headers = []
+self.sources = []
self._Config = type('Config', (object,), {})
self._TYPES = {}
self.includes = []
@@ -712,6 +713,12 @@
self.ctx.parse(source)
self.configure_types()
+def parse_header(self, header_path):
+self.headers.append(str(header_path))
+self.parsed_headers.append(header_path)
+self.ctx.parse(header_path.read())
+self.configure_types()
+
def add_typedef(self, name, obj, quals):
assert name not in self.definitions
tp = self.convert_type(obj, quals)
diff --git a/pypy/module/cpyext/test/test_api.py
b/pypy/module/cpyext/test/test_api.py
--- a/pypy/module/cpyext/test/test_api.py
+++ b/pypy/module/cpyext/test/test_api.py
@@ -5,7 +5,7 @@
from pypy.module.cpyext.state import State
from pypy.module.cpyext.api import (
slot_function, cpython_api, copy_header_files, INTERPLEVEL_API,
-Py_ssize_t, Py_ssize_tP, PyObject)
+Py_ssize_t, Py_ssize_tP, PyObject, cts)
from pypy.module.cpyext.test.test_cpyext import freeze_refcnts,
LeakCheckingTest
from pypy.interpreter.error import OperationError
from rpython.rlib import rawrefcount
@@ -113,7 +113,7 @@
@pytest.mark.skipif(os.environ.get('USER')=='root',
reason='root can write to all files')
def test_copy_header_files(tmpdir):
-copy_header_files(tmpdir, True)
+copy_header_files(cts, tmpdir, True)
def check(name):
f = tmpdir.join(name)
assert f.check(file=True)
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
@@ -41,8 +41,7 @@
PyType_Check, PyType_CheckExact = build_type_checkers("Type", "w_type")
-cdef = (parse_dir / 'cpyext_typeobject.h').read()
-cts.parse_source(cdef)
+cts.parse_header(parse_dir / 'cpyext_typeobject.h')
PyHeapTypeObjectStruct = cts.gettype('PyHeapTypeObject')
PyHeapTypeObject = cts.gettype('PyHeapTypeObject *')
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy missing-tp_new: close branch to be merged
Author: Matti Picus Branch: missing-tp_new Changeset: r89615:20df0e922a73 Date: 2017-01-16 19:13 +0200 http://bitbucket.org/pypy/pypy/changeset/20df0e922a73/ Log:close branch to be merged ___ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: merge missing-tp_new which improves support for app-level classes in cpyext
Author: Matti Picus Branch: Changeset: r89616:5b9b0f8a10c5 Date: 2017-01-16 19:15 +0200 http://bitbucket.org/pypy/pypy/changeset/5b9b0f8a10c5/ Log:merge missing-tp_new which improves support for app-level classes in cpyext 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 @@ -108,3 +108,14 @@ .. branch: TreeStain/fixed-typo-line-29-mostly-to-most-1484469416419 .. branch: TreeStain/main-lines-changed-in-l77-l83-made-para-1484471558033 + +.. branch: missing-tp_new + +Improve mixing app-level classes in c-extensions, especially if the app-level +class has a ``tp_new`` or ``tp_dealloc``. The issue is that c-extensions expect +all the method slots to be filled with a function pointer, where app-level will +search up the mro for an appropriate function at runtime. With this branch we +now fill many more slots in the c-extenion type objects. +Also fix for c-extension type that calls ``tp_hash`` during initialization +(str, unicode types), and fix instantiating c-extension types from built-in +classes by enforcing an order of instaniation. 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 @@ -40,6 +40,7 @@ from rpython.rlib import rawrefcount from rpython.rlib import rthread from rpython.rlib.debug import fatalerror_notb +from pypy.objspace.std.typeobject import W_TypeObject, find_best_base DEBUG_WRAPPER = True @@ -900,6 +901,7 @@ retval = fatal_value boxed_args = () tb = None +state = space.fromcache(State) try: if not we_are_translated() and DEBUG_WRAPPER: print >>sys.stderr, callable, @@ -918,7 +920,6 @@ boxed_args += (arg_conv, ) if pygilstate_ensure: boxed_args += (args[-1], ) -state = space.fromcache(State) try: result = callable(space, *boxed_args) if not we_are_translated() and DEBUG_WRAPPER: @@ -964,6 +965,7 @@ except Exception as e: unexpected_exception(pname, e, tb) _restore_gil_state(pygilstate_release, gilstate, gil_release, _gil_auto, tid) +state.check_and_raise_exception(always=True) return fatal_value assert lltype.typeOf(retval) == restype @@ -1124,6 +1126,34 @@ setup_init_functions(eci, prefix) return modulename.new(ext='') +def attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i): +# Start at i but make sure all the base classes are already attached +from pypy.module.cpyext.pyobject import get_typedescr, make_ref +if i in attached_objs: +return +py_obj = static_pyobjs[i] +w_obj = static_objs_w[i] +w_base = None +# w_obj can be NotImplemented, which is not a W_TypeObject +if isinstance(w_obj, W_TypeObject): +bases_w = w_obj.bases_w +if bases_w: +w_base = find_best_base(bases_w) +if w_base: +try: +j = static_objs_w.index(w_base) +except ValueError: +j = -1 +if j >=0 and j not in attached_objs: +attach_recursively(space, static_pyobjs, static_objs_w, + attached_objs, j) +w_type = space.type(w_obj) +typedescr = get_typedescr(w_type.layout.typedef) +py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, + make_ref(space, w_type)) +typedescr.attach(space, py_obj, w_obj) +attached_objs.append(i) + class StaticObjectBuilder(object): def __init__(self): @@ -1144,7 +1174,6 @@ def attach_all(self, space): # this is RPython, called once in pypy-c when it imports cpyext -from pypy.module.cpyext.pyobject import get_typedescr, make_ref from pypy.module.cpyext.typeobject import finish_type_1, finish_type_2 from pypy.module.cpyext.pyobject import track_reference # @@ -1154,14 +1183,9 @@ track_reference(space, static_pyobjs[i], static_objs_w[i]) # self.cpyext_type_init = [] +attached_objs = [] for i in range(len(static_objs_w)): -py_obj = static_pyobjs[i] -w_obj = static_objs_w[i] -w_type = space.type(w_obj) -typedescr = get_typedescr(w_type.layout.typedef) -py_obj.c_ob_type = rffi.cast(PyTypeObjectPtr, - make_ref(space, w_type)) -typedescr.attach(space, py_obj, w_obj) +attach_recursively(space, static_pyobjs, static_objs_w, attached_objs, i) cpyext_type_init = self.cpyext_type_init self.cpyext_type_init = None for pto, w_type in cpyext_type_init: diff --git a/pypy/module/cpyext/bytesobject.py b/pypy/module/cpyext/bytesobject.py --- a/pypy/mo
[pypy-commit] pypy rffi-parser-2: Add RPython compatible cts.cast()
Author: Ronan Lamy
Branch: rffi-parser-2
Changeset: r89617:ac221fcd46ab
Date: 2017-01-16 19:20 +
http://bitbucket.org/pypy/pypy/changeset/ac221fcd46ab/
Log:Add RPython compatible cts.cast()
diff --git a/pypy/module/cpyext/cparser.py b/pypy/module/cpyext/cparser.py
--- a/pypy/module/cpyext/cparser.py
+++ b/pypy/module/cpyext/cparser.py
@@ -10,6 +10,9 @@
from rpython.rlib.rfile import FILEP
from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rtyper.tool import rfficache, rffi_platform
+from rpython.flowspace.model import Constant, const
+from rpython.flowspace.specialcase import register_flow_sc
+from rpython.flowspace.flowcontext import FlowingError
_r_comment = re.compile(r"/\*.*?\*/|//([^\n\\]|\\.)*?$",
re.DOTALL | re.MULTILINE)
@@ -699,6 +702,7 @@
self.includes = []
self.struct_typedefs = {}
self._handled = set()
+self._frozen = False
if includes is not None:
for header in includes:
self.include(header)
@@ -740,8 +744,8 @@
self.structs[obj] = struct
if obj.fldtypes is not None:
struct.fields = zip(
- obj.fldnames,
- [self.convert_field(field) for field in obj.fldtypes])
+obj.fldnames,
+[self.convert_field(field) for field in obj.fldtypes])
return struct
def convert_field(self, obj):
@@ -833,6 +837,9 @@
result = result.TYPE
return result
+def cast(self, cdecl, value):
+return rffi.cast(self.gettype(cdecl), value)
+
def parse_func(self, cdecl):
cdecl = cdecl.strip()
if cdecl[-1] != ';':
@@ -843,6 +850,20 @@
FUNCP = self.convert_type(tp.as_function_pointer())
return decl.name, FUNCP.TO
+def _freeze_(self):
+if self._frozen:
+return True
+
+@register_flow_sc(self.cast)
+def sc_cast(ctx, v_decl, v_arg):
+if not isinstance(v_decl, Constant):
+raise FlowingError(
+"The first argument of cts.cast() must be a constant.")
+TP = self.gettype(v_decl.value)
+return ctx.appcall(rffi.cast, const(TP), v_arg)
+self._frozen = True
+return True
+
def parse_source(source, includes=None, headers=None, configure_now=True):
cts = CTypeSpace(headers=headers, includes=includes)
diff --git a/pypy/module/cpyext/test/test_cparser.py
b/pypy/module/cpyext/test/test_cparser.py
--- a/pypy/module/cpyext/test/test_cparser.py
+++ b/pypy/module/cpyext/test/test_cparser.py
@@ -1,3 +1,6 @@
+from rpython.flowspace.model import const
+from rpython.flowspace.objspace import build_flow
+from rpython.translator.simplify import simplify_graph
from rpython.rtyper.lltypesystem import rffi, lltype
from pypy.module.cpyext.cparser import parse_source, CTypeSpace
@@ -164,6 +167,7 @@
cts = parse_source(decl)
assert cts.gettype('Py_ssize_t') == rffi.SSIZE_T
assert cts.gettype('TestFloatObject *').TO.c_ob_refcnt == rffi.SSIZE_T
+assert cts.cast('Py_ssize_t', 42) == rffi.cast(rffi.SSIZE_T, 42)
def test_parse_funcdecl():
decl = """
@@ -185,3 +189,16 @@
assert name == 'some_func'
assert FUNC.RESULT == cts.gettype('func_t')
assert FUNC.ARGS == (cts.gettype('TestFloatObject *'),)
+
+def test_translate_cast():
+cdef = "typedef ssize_t Py_ssize_t;"
+cts = parse_source(cdef)
+
+def f():
+return cts.cast('Py_ssize_t*', 0)
+graph = build_flow(f)
+simplify_graph(graph)
+assert len(graph.startblock.operations) == 1
+op = graph.startblock.operations[0]
+assert op.args[0] == const(rffi.cast)
+assert op.args[1].value is cts.gettype('Py_ssize_t*')
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy rffi-parser-2: Make cts.gettype() RPython
Author: Ronan Lamy
Branch: rffi-parser-2
Changeset: r89618:660f34981e06
Date: 2017-01-16 19:33 +
http://bitbucket.org/pypy/pypy/changeset/660f34981e06/
Log:Make cts.gettype() RPython
diff --git a/pypy/module/cpyext/cparser.py b/pypy/module/cpyext/cparser.py
--- a/pypy/module/cpyext/cparser.py
+++ b/pypy/module/cpyext/cparser.py
@@ -861,6 +861,14 @@
"The first argument of cts.cast() must be a constant.")
TP = self.gettype(v_decl.value)
return ctx.appcall(rffi.cast, const(TP), v_arg)
+
+@register_flow_sc(self.gettype)
+def sc_gettype(ctx, v_decl):
+if not isinstance(v_decl, Constant):
+raise FlowingError(
+"The argument of cts.gettype() must be a constant.")
+return const(self.gettype(v_decl.value))
+
self._frozen = True
return True
diff --git a/pypy/module/cpyext/test/test_cparser.py
b/pypy/module/cpyext/test/test_cparser.py
--- a/pypy/module/cpyext/test/test_cparser.py
+++ b/pypy/module/cpyext/test/test_cparser.py
@@ -202,3 +202,17 @@
op = graph.startblock.operations[0]
assert op.args[0] == const(rffi.cast)
assert op.args[1].value is cts.gettype('Py_ssize_t*')
+
+def test_translate_gettype():
+cdef = "typedef ssize_t Py_ssize_t;"
+cts = parse_source(cdef)
+
+def f():
+return cts.gettype('Py_ssize_t*')
+graph = build_flow(f)
+simplify_graph(graph)
+# Check that the result is constant-folded
+assert graph.startblock.operations == []
+[link] = graph.startblock.exits
+assert link.target is graph.returnblock
+assert link.args[0] == const(rffi.CArrayPtr(rffi.SSIZE_T))
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Last missing __objclass__
Author: Armin Rigo Branch: Changeset: r89619:4dc79c0c13a6 Date: 2017-01-16 20:37 +0100 http://bitbucket.org/pypy/pypy/changeset/4dc79c0c13a6/ Log:Last missing __objclass__ diff --git a/pypy/objspace/std/test/test_typeobject.py b/pypy/objspace/std/test/test_typeobject.py --- a/pypy/objspace/std/test/test_typeobject.py +++ b/pypy/objspace/std/test/test_typeobject.py @@ -1333,3 +1333,4 @@ assert int.__dict__['imag'].__objclass__ is int assert file.closed.__objclass__ is file assert type.__dict__['__name__'].__objclass__ is type +assert type.__dict__['__doc__'].__objclass__ is type diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py --- a/pypy/objspace/std/typeobject.py +++ b/pypy/objspace/std/typeobject.py @@ -958,7 +958,7 @@ __base__ = GetSetProperty(descr__base), __mro__ = GetSetProperty(descr_get__mro__), __dict__=GetSetProperty(type_get_dict), -__doc__ = GetSetProperty(descr__doc), +__doc__ = GetSetProperty(descr__doc, cls=W_TypeObject), mro = gateway.interp2app(descr_mro), __flags__ = GetSetProperty(descr__flags), __module__ = GetSetProperty(descr_get__module, descr_set__module), ___ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix failing test, which now passes
Author: Matti Picus
Branch:
Changeset: r89620:87475b57a469
Date: 2017-01-16 23:00 +0200
http://bitbucket.org/pypy/pypy/changeset/87475b57a469/
Log:fix failing test, which now passes
diff --git a/lib-python/2.7/test/test_capi.py b/lib-python/2.7/test/test_capi.py
--- a/lib-python/2.7/test/test_capi.py
+++ b/lib-python/2.7/test/test_capi.py
@@ -26,7 +26,6 @@
skips = []
if support.check_impl_detail(pypy=True):
skips += [
-'test_broken_memoryview',
'test_buildvalue_N',
'test_capsule',
'test_lazy_hash_inheritance',
diff --git a/lib_pypy/_testcapimodule.c b/lib_pypy/_testcapimodule.c
--- a/lib_pypy/_testcapimodule.c
+++ b/lib_pypy/_testcapimodule.c
@@ -2780,6 +2780,9 @@
m = Py_InitModule("_testcapi", TestMethods);
if (m == NULL)
return;
+
+if (PyType_Ready(&_MemoryViewTester_Type) < 0)
+return;
Py_TYPE(&_HashInheritanceTester_Type)=&PyType_Type;
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix test - call Py_DecRef on PyObject to allow finalizer to run
Author: Matti Picus
Branch:
Changeset: r89621:13bdc04dc6d2
Date: 2017-01-16 23:20 +0200
http://bitbucket.org/pypy/pypy/changeset/13bdc04dc6d2/
Log:fix test - call Py_DecRef on PyObject to allow finalizer to run
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,13 +30,14 @@
assert view.c_len == 5
o = rffi.charp2str(view.c_buf)
assert o == 'hello'
-w_mv = from_ref(space, api.PyMemoryView_FromBuffer(view))
+ref = api.PyMemoryView_FromBuffer(view)
+w_mv = from_ref(space, ref)
for f in ('format', 'itemsize', 'ndim', 'readonly',
'shape', 'strides', 'suboffsets'):
w_f = space.wrap(f)
assert space.eq_w(space.getattr(w_mv, w_f),
space.getattr(w_memoryview, w_f))
-
+api.Py_DecRef(ref)
class AppTestPyBuffer_FillInfo(AppTestCpythonExtensionBase):
def test_fillWithObject(self):
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: update for recent release of numpy 1.12
Author: Matti Picus Branch: extradoc Changeset: r846:badcb41df7e1 Date: 2017-01-16 23:35 +0200 http://bitbucket.org/pypy/pypy.org/changeset/badcb41df7e1/ Log:update for recent release of numpy 1.12 diff --git a/download.html b/download.html --- a/download.html +++ b/download.html @@ -235,14 +235,14 @@ the Python side and NumPy objects are mediated through the slower cpyext layer (which hurts a few benchmarks that do a lot of element-by-element array accesses, for example). -Installation works on any recent PyPy (the release above is fine), -but you need the current developement version of NumPy. The reason -is that some PyPy-specific fixes have been merged back into NumPy, -and they are not yet in a released version of NumPy. +Installation works on any recent PyPy (the release above is fine, a recent +nightly will implement more of the new buffer protocol). +The currently released numpy 1.12 works except for nditers with the +updateifcopy flag. For example, without using a virtualenv: $ ./pypy-xxx/bin/pypy -m ensurepip -$ ./pypy-xxx/bin/pip install cython git+https://github.com/numpy/numpy.git +$ ./pypy-xxx/bin/pip install cython numpy (See the general http://doc.pypy.org/en/latest/install.html";>installation documentation for more.) diff --git a/source/download.txt b/source/download.txt --- a/source/download.txt +++ b/source/download.txt @@ -259,14 +259,14 @@ layer (which hurts a few benchmarks that do a lot of element-by-element array accesses, for example). -Installation works on any recent PyPy (the release_ above is fine), -but you need the current developement version *of NumPy*. The reason -is that some PyPy-specific fixes have been merged back into NumPy, -and they are not yet in a released version of NumPy. +Installation works on any recent PyPy (the release_ above is fine, a recent +nightly will implement more of the new buffer protocol). +The currently released numpy 1.12 works except for ``nditers`` with the +``updateifcopy`` flag. For example, without using a virtualenv:: $ ./pypy-xxx/bin/pypy -m ensurepip -$ ./pypy-xxx/bin/pip install cython git+https://github.com/numpy/numpy.git +$ ./pypy-xxx/bin/pip install cython numpy (See the general `installation documentation`_ for more.) ___ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy rffi-parser-2: Use cts.cast() in a few random places
Author: Ronan Lamy
Branch: rffi-parser-2
Changeset: r89622:b370fab11d05
Date: 2017-01-16 22:03 +
http://bitbucket.org/pypy/pypy/changeset/b370fab11d05/
Log:Use cts.cast() in a few random places
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
@@ -32,7 +32,7 @@
from pypy.module.cpyext.state import State
from pypy.module.cpyext.structmember import PyMember_GetOne, PyMember_SetOne
from pypy.module.cpyext.typeobjectdefs import (
-PyGetSetDef, PyMemberDef, newfunc, getter, setter,
+PyGetSetDef, PyMemberDef,
PyNumberMethods, PySequenceMethods, PyBufferProcs)
from pypy.objspace.std.typeobject import W_TypeObject, find_best_base
@@ -42,7 +42,6 @@
PyType_Check, PyType_CheckExact = build_type_checkers("Type", "w_type")
cts.parse_header(parse_dir / 'cpyext_typeobject.h')
-PyHeapTypeObjectStruct = cts.gettype('PyHeapTypeObject')
PyHeapTypeObject = cts.gettype('PyHeapTypeObject *')
@@ -75,9 +74,9 @@
py_getsetdef.c_doc = rffi.cast(rffi.CCHARP, 0)
py_getsetdef.c_name = rffi.str2charp(getsetprop.getname(space))
# XXX FIXME - actually assign these !!!
-py_getsetdef.c_get = rffi.cast(getter, 0)
-py_getsetdef.c_set = rffi.cast(setter, 0)
-py_getsetdef.c_closure = rffi.cast(rffi.VOIDP, 0)
+py_getsetdef.c_get = cts.cast('getter', 0)
+py_getsetdef.c_set = cts.cast('setter', 0)
+py_getsetdef.c_closure = cts.cast('void*', 0)
return py_getsetdef
@@ -178,7 +177,7 @@
def memberdescr_realize(space, obj):
# XXX NOT TESTED When is this ever called?
-member = rffi.cast(lltype.Ptr(PyMemberDef), obj)
+member = cts.cast('PyMemberDef*', obj)
w_type = from_ref(space, rffi.cast(PyObject, obj.c_ob_type))
w_obj = space.allocate_instance(W_MemberDescr, w_type)
w_obj.__init__(member, w_type)
@@ -701,7 +700,7 @@
# things are not initialized yet. So in this case, simply use
# str2charp() and "leak" the string.
w_typename = space.getattr(w_type, space.wrap('__name__'))
-heaptype = rffi.cast(PyHeapTypeObject, pto)
+heaptype = cts.cast('PyHeapTypeObject*', pto)
heaptype.c_ht_name = make_ref(space, w_typename)
from pypy.module.cpyext.bytesobject import PyString_AsString
pto.c_tp_name = PyString_AsString(space, heaptype.c_ht_name)
@@ -730,7 +729,7 @@
# will be filled later on with the correct value
# may not be 0
if space.is_w(w_type, space.w_object):
-pto.c_tp_new = rffi.cast(newfunc, 1)
+pto.c_tp_new = cts.cast('newfunc', 1)
update_all_slots(space, w_type, pto)
pto.c_tp_flags |= Py_TPFLAGS_READY
return pto
@@ -847,7 +846,8 @@
if not py_type.c_tp_as_sequence:
py_type.c_tp_as_sequence = base.c_tp_as_sequence
py_type.c_tp_flags |= base.c_tp_flags & Py_TPFLAGS_HAVE_INPLACEOPS
-if not py_type.c_tp_as_mapping: py_type.c_tp_as_mapping =
base.c_tp_as_mapping
+if not py_type.c_tp_as_mapping:
+py_type.c_tp_as_mapping = base.c_tp_as_mapping
#if not py_type.c_tp_as_buffer: py_type.c_tp_as_buffer =
base.c_tp_as_buffer
return w_obj
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy rffi-parser-2: hg merge default
Author: Ronan Lamy
Branch: rffi-parser-2
Changeset: r89623:ebbd6a0d8773
Date: 2017-01-17 01:11 +
http://bitbucket.org/pypy/pypy/changeset/ebbd6a0d8773/
Log:hg merge default
diff --git a/lib-python/2.7/sqlite3/test/regression.py
b/lib-python/2.7/sqlite3/test/regression.py
--- a/lib-python/2.7/sqlite3/test/regression.py
+++ b/lib-python/2.7/sqlite3/test/regression.py
@@ -351,10 +351,7 @@
self.assertRaises(ValueError, cur.execute, " \0select 2")
self.assertRaises(ValueError, cur.execute, "select 2\0")
-@test_support.impl_detail(pypy=False)
def CheckCommitCursorReset(self):
-# This test is for logic added in 2.7.13 which PyPy doesn't
-# implement. See http://bugs.python.org/issue29006
"""
Connection.commit() did reset cursors, which made sqlite3
to return rows multiple times when fetched from cursors
diff --git a/lib-python/2.7/test/test_capi.py b/lib-python/2.7/test/test_capi.py
--- a/lib-python/2.7/test/test_capi.py
+++ b/lib-python/2.7/test/test_capi.py
@@ -26,7 +26,6 @@
skips = []
if support.check_impl_detail(pypy=True):
skips += [
-'test_broken_memoryview',
'test_buildvalue_N',
'test_capsule',
'test_lazy_hash_inheritance',
diff --git a/lib-python/2.7/test/test_multiprocessing.py
b/lib-python/2.7/test/test_multiprocessing.py
--- a/lib-python/2.7/test/test_multiprocessing.py
+++ b/lib-python/2.7/test/test_multiprocessing.py
@@ -1969,9 +1969,10 @@
if not gc.isenabled():
gc.enable()
self.addCleanup(gc.disable)
-#thresholds = gc.get_threshold()
-#self.addCleanup(gc.set_threshold, *thresholds)
-#gc.set_threshold(10)
+if test_support.check_impl_detail(cpython=True):
+thresholds = gc.get_threshold()
+self.addCleanup(gc.set_threshold, *thresholds)
+gc.set_threshold(10)
# perform numerous block allocations, with cyclic references to make
# sure objects are collected asynchronously by the gc
diff --git a/lib_pypy/_sqlite3.py b/lib_pypy/_sqlite3.py
--- a/lib_pypy/_sqlite3.py
+++ b/lib_pypy/_sqlite3.py
@@ -220,6 +220,7 @@
self.__statements_counter = 0
self.__rawstatements = set()
self._statement_cache = _StatementCache(self, cached_statements)
+self.__statements_already_committed = []
self.__func_cache = {}
self.__aggregates = {}
@@ -363,6 +364,14 @@
if cursor is not None:
cursor._reset = True
+def _reset_already_committed_statements(self):
+lst = self.__statements_already_committed
+self.__statements_already_committed = []
+for weakref in lst:
+statement = weakref()
+if statement is not None:
+statement._reset()
+
@_check_thread_wrap
@_check_closed_wrap
def __call__(self, sql):
@@ -418,15 +427,18 @@
if not self._in_transaction:
return
-# The following line is a KNOWN DIFFERENCE with CPython 2.7.13.
-# More precisely, the corresponding line was removed in the
-# version 2.7.13 of CPython, but this is causing troubles for
-# PyPy (and potentially for CPython too):
-#
-# http://bugs.python.org/issue29006
-#
-# So for now, we keep this line.
-self.__do_all_statements(Statement._reset, False)
+# PyPy fix for non-refcounting semantics: since 2.7.13 (and in
+# <= 2.6.x), the statements are not automatically reset upon
+# commit. However, if this is followed by some specific SQL
+# operations like "drop table", these open statements come in
+# the way and cause the "drop table" to fail. On CPython the
+# problem is much less important because typically all the old
+# statements are freed already by reference counting. So here,
+# we copy all the still-alive statements to another list which
+# is usually ignored, except if we get SQLITE_LOCKED
+# afterwards---at which point we reset all statements in this
+# list.
+self.__statements_already_committed = self.__statements[:]
statement_star = _ffi.new('sqlite3_stmt **')
ret = _lib.sqlite3_prepare_v2(self._db, b"COMMIT", -1,
@@ -827,8 +839,18 @@
self.__statement._set_params(params)
# Actually execute the SQL statement
+
ret = _lib.sqlite3_step(self.__statement._statement)
+# PyPy: if we get SQLITE_LOCKED, it's probably because
+# one of the cursors created previously is still alive
+# and not reset and the operation we're trying to do
+# makes Sqlite unhappy about that. In that case, we
+# automatically reset all old cursors and try again.
+if ret == _lib.SQLITE_LOCKED:
+
[pypy-commit] pypy rffi-parser-2: Define tp_name and tp_doc as const char*
Author: Ronan Lamy
Branch: rffi-parser-2
Changeset: r89624:ca94f56f64e0
Date: 2017-01-17 01:46 +
http://bitbucket.org/pypy/pypy/changeset/ca94f56f64e0/
Log:Define tp_name and tp_doc as const char*
diff --git a/pypy/module/cpyext/parse/cpyext_object.h
b/pypy/module/cpyext/parse/cpyext_object.h
--- a/pypy/module/cpyext/parse/cpyext_object.h
+++ b/pypy/module/cpyext/parse/cpyext_object.h
@@ -226,7 +226,7 @@
typedef struct _typeobject {
PyObject_VAR_HEAD
- /* const */ char *tp_name; /* For printing, in format "."
*/
+ const char *tp_name; /* For printing, in format "." */
Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
/* Methods to implement standard operations */
@@ -258,7 +258,7 @@
/* Flags to define presence of optional/expanded features */
long tp_flags;
- /*const*/ char *tp_doc; /* Documentation string */
+ const char *tp_doc; /* Documentation string */
/* Assigned meaning in release 2.0 */
/* call function for all accessible objects */
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
@@ -732,9 +732,10 @@
heaptype = cts.cast('PyHeapTypeObject*', pto)
heaptype.c_ht_name = make_ref(space, w_typename)
from pypy.module.cpyext.bytesobject import PyString_AsString
-pto.c_tp_name = PyString_AsString(space, heaptype.c_ht_name)
+pto.c_tp_name = cts.cast('const char *',
+PyString_AsString(space, heaptype.c_ht_name))
else:
-pto.c_tp_name = rffi.str2charp(w_type.name)
+pto.c_tp_name = cts.cast('const char*', rffi.str2charp(w_type.name))
# uninitialized fields:
# c_tp_print
# XXX implement
___
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: fix translation
Author: Philip Jenvey Branch: py3.5 Changeset: r89625:340c549c6f11 Date: 2017-01-16 21:10 -0800 http://bitbucket.org/pypy/pypy/changeset/340c549c6f11/ Log:fix translation diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py --- a/pypy/interpreter/function.py +++ b/pypy/interpreter/function.py @@ -544,7 +544,7 @@ except OperationError as e: if not e.match(space, space.w_TypeError): raise -name = '?' +name = u'?' objrepr = space.unicode_w(space.repr(self.w_instance)) s = u'' % (name, objrepr) return space.wrap(s) ___ pypy-commit mailing list [email protected] https://mail.python.org/mailman/listinfo/pypy-commit
