Author: Matti Picus <[email protected]>
Branch: missing-tp_new
Changeset: r88406:b35f9dc08af7
Date: 2016-11-16 10:49 +0200
http://bitbucket.org/pypy/pypy/changeset/b35f9dc08af7/
Log: merge default into branch
diff --git a/pypy/doc/faq.rst b/pypy/doc/faq.rst
--- a/pypy/doc/faq.rst
+++ b/pypy/doc/faq.rst
@@ -90,6 +90,10 @@
Do CPython Extension modules work with PyPy?
--------------------------------------------
+**First note that some Linux distributions (e.g. Ubuntu, Debian) split
+PyPy into several packages. If you installed a package called "pypy",
+then you may also need to install "pypy-dev" for the following to work.**
+
We have experimental support for CPython extension modules, so
they run with minor changes. This has been a part of PyPy since
the 1.4 release, but support is still in beta phase. CPython
diff --git a/pypy/module/cpyext/setobject.py b/pypy/module/cpyext/setobject.py
--- a/pypy/module/cpyext/setobject.py
+++ b/pypy/module/cpyext/setobject.py
@@ -11,6 +11,13 @@
PySet_Check, PySet_CheckExact = build_type_checkers("Set")
@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
+def PyAnySet_Check(space, w_obj):
+ """Return true if obj is a set object, a frozenset object, or an
+ instance of a subtype."""
+ return (space.isinstance_w(w_obj, space.gettypefor(W_SetObject)) or
+ space.isinstance_w(w_obj, space.gettypefor(W_FrozensetObject)))
+
+@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
def PyAnySet_CheckExact(space, w_obj):
"""Return true if obj is a set object or a frozenset object but
not an instance of a subtype."""
diff --git a/pypy/module/cpyext/stubs.py b/pypy/module/cpyext/stubs.py
--- a/pypy/module/cpyext/stubs.py
+++ b/pypy/module/cpyext/stubs.py
@@ -1476,18 +1476,6 @@
raise NotImplementedError
@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
-def PyAnySet_Check(space, p):
- """Return true if p is a set object, a frozenset object, or an
- instance of a subtype."""
- raise NotImplementedError
-
-@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
-def PyAnySet_CheckExact(space, p):
- """Return true if p is a set object or a frozenset object but
- not an instance of a subtype."""
- raise NotImplementedError
-
-@cpython_api([PyObject], rffi.INT_real, error=CANNOT_FAIL)
def PyFrozenSet_CheckExact(space, p):
"""Return true if p is a frozenset object but not an instance of a
subtype."""
diff --git a/pypy/module/cpyext/test/test_setobject.py
b/pypy/module/cpyext/test/test_setobject.py
--- a/pypy/module/cpyext/test/test_setobject.py
+++ b/pypy/module/cpyext/test/test_setobject.py
@@ -41,11 +41,19 @@
api.PySet_Clear(w_set)
assert space.len_w(w_set) == 0
- def test_anyset_checkexact(self, space, api):
+ def test_anyset_check(self, space, api):
w_set = api.PySet_New(space.wrap([1, 2, 3, 4]))
w_frozenset = space.newfrozenset([space.wrap(i) for i in [1, 2, 3, 4]])
assert api.PyAnySet_CheckExact(w_set)
assert api.PyAnySet_CheckExact(w_frozenset)
+ assert api.PyAnySet_Check(w_set)
+ assert api.PyAnySet_Check(w_frozenset)
+ w_instance = space.appexec([], """():
+ class MySet(set):
+ pass
+ return MySet()
+ """)
+ assert api.PyAnySet_Check(w_instance)
class AppTestSetObject(AppTestCpythonExtensionBase):
def test_set_macro_cast(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit