[prev in list] [next in list] [prev in thread] [next in thread]
List: pypy-svn
Subject: [pypy-commit] pypy missing-tp_new: slot_tp_new
From: arigo <pypy.commits () gmail ! com>
Date: 2016-10-30 16:48:20
Message-ID: 58162454.c1a5c20a.124c4.f073 () mx ! google ! com
[Download RAW message or body]
Author: Armin Rigo <arigo@tunes.org>
Branch: missing-tp_new
Changeset: r87996:c0e856a6f037
Date: 2016-10-30 17:47 +0100
http://bitbucket.org/pypy/pypy/changeset/c0e856a6f037/
Log: slot_tp_new
diff --git a/pypy/module/cpyext/userslot.py b/pypy/module/cpyext/userslot.py
--- a/pypy/module/cpyext/userslot.py
+++ b/pypy/module/cpyext/userslot.py
@@ -10,7 +10,10 @@
'__xxx__' special methods) after initalization of the PyTypeObject.
"""
+from pypy.interpreter.error import oefmt
+from pypy.interpreter.argument import Arguments
from pypy.module.cpyext.api import cpython_api, PyObject, Py_ssize_t
+from pypy.module.cpyext.api import PyTypeObjectPtr
@cpython_api([PyObject], Py_ssize_t, error=-1, header=None)
@@ -24,3 +27,13 @@
@cpython_api([PyObject, PyObject], PyObject, header=None)
def slot_nb_add(space, w_obj1, w_obj2):
return space.add(w_obj1, w_obj2)
+
+@cpython_api([PyTypeObjectPtr, PyObject, PyObject], PyObject, header=None)
+def slot_tp_new(space, w_type, w_args, w_kwds):
+ _, w_descr = space.lookup_in_type_where(w_type, '__new__')
+ if w_descr is None:
+ raise oefmt(space.w_RuntimeError, "cpyext: '__new__' not found")
+ # w_descr is typically a StaticMethod
+ args = Arguments(space, [w_type],
+ w_stararg=w_args, w_starstararg=w_kwds)
+ return space.call_args(space.get(w_descr, w_type), args)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic