[pypy-commit] pypy py3.5: hg merge default
rlamy
pypy.commits at gmail.com
Sun Dec 11 01:42:14 EST 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r89008:b4df9ec64b22
Date: 2016-12-11 06:30 +0000
http://bitbucket.org/pypy/pypy/changeset/b4df9ec64b22/
Log: hg merge default
diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -27,7 +27,7 @@
def get_dealloc(self):
from pypy.module.cpyext.typeobject import subtype_dealloc
- return subtype_dealloc
+ return subtype_dealloc.api_func
def allocate(self, space, w_type, itemcount=0):
# similar to PyType_GenericAlloc?
@@ -108,7 +108,7 @@
if tp_dealloc:
def get_dealloc(self):
- return tp_dealloc
+ return tp_dealloc.api_func
if tp_attach:
def attach(self, space, pyobj, w_obj):
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
@@ -7,12 +7,12 @@
cpython_api, generic_cpy_call, PyObject, Py_ssize_t,
Py_buffer, mangle_name, pypy_decl)
from pypy.module.cpyext.typeobjectdefs import (
- unaryfunc, wrapperfunc, ternaryfunc, PyTypeObjectPtr, binaryfunc, ternaryfunc,
+ unaryfunc, ternaryfunc, PyTypeObjectPtr, binaryfunc,
getattrfunc, getattrofunc, setattrofunc, lenfunc, ssizeargfunc, inquiry,
ssizessizeargfunc, ssizeobjargproc, iternextfunc, initproc, richcmpfunc,
cmpfunc, hashfunc, descrgetfunc, descrsetfunc, objobjproc, objobjargproc,
getbufferproc, ssizessizeobjargproc)
-from pypy.module.cpyext.pyobject import from_ref, make_ref, Py_DecRef
+from pypy.module.cpyext.pyobject import make_ref, Py_DecRef
from pypy.module.cpyext.pyerrors import PyErr_Occurred
from pypy.module.cpyext.memoryobject import fill_Py_buffer
from pypy.module.cpyext.state import State
@@ -20,9 +20,11 @@
from pypy.interpreter.argument import Arguments
from rpython.rlib.buffer import Buffer
from rpython.rlib.unroll import unrolling_iterable
-from rpython.rlib.objectmodel import specialize
+from rpython.rlib.objectmodel import specialize, not_rpython
from rpython.rlib.rarithmetic import widen
from rpython.tool.sourcetools import func_renamer
+from rpython.flowspace.model import Constant
+from rpython.flowspace.specialcase import register_flow_sc
from rpython.rtyper.annlowlevel import llhelper
from pypy.module.sys.version import CPYTHON_VERSION
@@ -59,9 +61,17 @@
"expected %d-%d arguments, got %d",
low, high, space.len_w(w_ob))
+ at not_rpython
def llslot(space, func):
return llhelper(func.api_func.functype, func.api_func.get_wrapper(space))
+ at register_flow_sc(llslot)
+def sc_llslot(ctx, v_space, v_func):
+ assert isinstance(v_func, Constant)
+ get_llhelper = v_func.value.api_func.get_llhelper
+ return ctx.appcall(get_llhelper, v_space)
+
+
def wrap_init(space, w_self, w_args, func, w_kwargs):
func_init = rffi.cast(initproc, func)
res = generic_cpy_call(space, func_init, w_self, w_args, w_kwargs)
@@ -416,9 +426,10 @@
try:
return SLOTS[key]
except KeyError:
- ret = build_slot_tp_function(space, typedef, name)
- SLOTS[key] = ret
- return ret
+ slot_func = build_slot_tp_function(space, typedef, name)
+ api_func = slot_func.api_func if slot_func else None
+ SLOTS[key] = api_func
+ return api_func
def build_slot_tp_function(space, typedef, name):
w_type = space.gettypeobject(typedef)
@@ -927,8 +938,8 @@
slotdefs = sorted(slotdefs, key=slotdef_sort_key)
slotdefs_for_tp_slots = unrolling_iterable(
- [(x.method_name, x.slot_name, x.slot_names, x.slot_func)
- for x in slotdefs])
+ [(x.method_name, x.slot_name, x.slot_names,
+ x.slot_func.api_func if x.slot_func else None) for x in slotdefs])
slotdefs_for_wrappers = unrolling_iterable(
[(x.method_name, x.slot_names, x.wrapper_func, x.wrapper_func_kwds, x.doc)
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
@@ -246,20 +246,21 @@
# coming from a parent C type.
typedef = w_type.layout.typedef
- for method_name, slot_name, slot_names, slot_func in slotdefs_for_tp_slots:
+ for method_name, slot_name, slot_names, slot_apifunc in slotdefs_for_tp_slots:
w_descr = w_type.lookup(method_name)
if w_descr is None:
# XXX special case iternext
continue
- if slot_func is None and typedef is not None:
- slot_func = get_slot_tp_function(space, typedef, slot_name)
- if not slot_func:
+ if slot_apifunc is None and typedef is not None:
+ slot_apifunc = get_slot_tp_function(space, typedef, slot_name)
+ if not slot_apifunc:
if WARN_ABOUT_MISSING_SLOT_FUNCTIONS:
- os.write(2, "%s defined by %s but no slot function defined!\n" % (
+ os.write(2,
+ "%s defined by %s but no slot function defined!\n" % (
method_name, w_type.getname(space)))
continue
- slot_func_helper = llslot(space, slot_func)
+ slot_func_helper = slot_apifunc.get_llhelper(space)
# XXX special case wrapper-functions and use a "specific" slot func
@@ -570,7 +571,7 @@
# dealloc
if space.gettypeobject(w_type.layout.typedef) is w_type:
# only for the exact type, like 'space.w_tuple' or 'space.w_list'
- pto.c_tp_dealloc = llslot(space, typedescr.get_dealloc())
+ pto.c_tp_dealloc = typedescr.get_dealloc().get_llhelper(space)
else:
# for all subtypes, use subtype_dealloc()
pto.c_tp_dealloc = llslot(space, subtype_dealloc)
More information about the pypy-commit
mailing list