[pypy-commit] pypy reflex-support: improved error reporting for unknown typed data members
wlav
noreply at buildbot.pypy.org
Thu Jul 21 14:15:31 CEST 2011
Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r45814:d3333099ce6f
Date: 2011-07-21 05:15 -0700
http://bitbucket.org/pypy/pypy/changeset/d3333099ce6f/
Log: improved error reporting for unknown typed data members
diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py
--- a/pypy/module/cppyy/converter.py
+++ b/pypy/module/cppyy/converter.py
@@ -43,22 +43,22 @@
fieldptr = rffi.cast(rffi.CCHARP, offset)
return fieldptr
- def _is_abstract(self):
- raise NotImplementedError(
- "abstract base class" ) # more detailed part is not rpython: (actual: %s)" % type(self).__name__)
+ def _is_abstract(self, space):
+ raise OperationError(space.w_NotImplementedError,
+ space.wrap("no converter available")) # more detailed part is not rpython: (actual: %s)" % type(self).__name__))
def convert_argument(self, space, w_obj, address):
- self._is_abstract()
+ self._is_abstract(space)
def convert_argument_libffi(self, space, w_obj, argchain):
from pypy.module.cppyy.interp_cppyy import FastCallNotPossible
raise FastCallNotPossible
def from_memory(self, space, w_obj, w_type, offset):
- self._is_abstract()
+ self._is_abstract(space)
def to_memory(self, space, w_obj, w_value, offset):
- self._is_abstract()
+ self._is_abstract(space)
def free_argument(self, arg):
pass
diff --git a/pypy/module/cppyy/pythonify.py b/pypy/module/cppyy/pythonify.py
--- a/pypy/module/cppyy/pythonify.py
+++ b/pypy/module/cppyy/pythonify.py
@@ -74,7 +74,13 @@
if not rettype: # return builtin type
cppclass = None
else: # return instance
+ try:
cppclass = get_cppclass(rettype)
+ except AttributeError, e:
+ import warnings
+ warnings.warn("class %s unknown: no data member access" % rettype,
+ RuntimeWarning)
+ cppclass = None
if cppdm.is_static():
def binder(obj):
return cppdm.get(None, cppclass)
diff --git a/pypy/module/cppyy/test/fragile.h b/pypy/module/cppyy/test/fragile.h
--- a/pypy/module/cppyy/test/fragile.h
+++ b/pypy/module/cppyy/test/fragile.h
@@ -28,4 +28,15 @@
void overload(int, no_such_class* p = 0) {}
};
+class E {
+public:
+ E() : m_pp_no_such(0), m_pp_a(0) {}
+
+ virtual int check() { return (int)'E'; }
+ void overload(no_such_class**) {}
+
+ no_such_class** m_pp_no_such;
+ A** m_pp_a;
+};
+
} // namespace fragile
diff --git a/pypy/module/cppyy/test/fragile.xml b/pypy/module/cppyy/test/fragile.xml
--- a/pypy/module/cppyy/test/fragile.xml
+++ b/pypy/module/cppyy/test/fragile.xml
@@ -2,9 +2,6 @@
<namespace name="fragile" />
- <class name="fragile::A" />
- <class name="fragile::B" />
- <class name="fragile::C" />
- <class name="fragile::D" />
+ <class pattern="fragile::[A-Z]" />
</lcgdict>
diff --git a/pypy/module/cppyy/test/test_fragile.py b/pypy/module/cppyy/test/test_fragile.py
--- a/pypy/module/cppyy/test/test_fragile.py
+++ b/pypy/module/cppyy/test/test_fragile.py
@@ -14,7 +14,7 @@
if err:
raise OSError("'make' failed (see stderr)")
-class AppTestSTL:
+class AppTestFRAGILE:
def setup_class(cls):
cls.space = space
env = os.environ
@@ -65,3 +65,24 @@
d = fragile.D()
raises(TypeError, d.overload, None)
+ raises(TypeError, d.overload, None, None, None)
+
+ # TODO: the following fails in the fast path, b/c the default
+ # arguments are not properly filled
+ #d.overload('a')
+ #d.overload(1)
+
+ def test04_unsupported_arguments(self):
+ """Test arguments that are yet unsupported"""
+
+ import cppyy
+
+ assert cppyy.gbl.fragile == cppyy.gbl.fragile
+ fragile = cppyy.gbl.fragile
+
+ assert fragile.E == fragile.E
+ assert fragile.E().check() == ord('E')
+
+ e = fragile.E()
+ raises(TypeError, e.overload, None)
+ raises(NotImplementedError, getattr, e, 'm_pp_no_such')
More information about the pypy-commit
mailing list