aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Lamy <ronan.lamy@gmail.com>2020-10-23 17:31:45 +0100
committerRonan Lamy <ronan.lamy@gmail.com>2020-10-23 17:31:45 +0100
commit911f3abc6859ea819925904134728d1c7c0eae4f (patch)
tree99d4ff3340f4cf8f2d32c2a6650f25b903e36374 /rpython
parentConfigure named structs, without requiring a spurious typedef (diff)
downloadpypy-911f3abc6859ea819925904134728d1c7c0eae4f.tar.gz
pypy-911f3abc6859ea819925904134728d1c7c0eae4f.tar.bz2
pypy-911f3abc6859ea819925904134728d1c7c0eae4f.zip
Raise meaningful error when trying to configure an undefined struct
Diffstat (limited to 'rpython')
-rw-r--r--rpython/tool/cparser/cts.py2
-rw-r--r--rpython/tool/cparser/test/test_cts.py6
2 files changed, 4 insertions, 4 deletions
diff --git a/rpython/tool/cparser/cts.py b/rpython/tool/cparser/cts.py
index ab9b781bd3..35f4763fbd 100644
--- a/rpython/tool/cparser/cts.py
+++ b/rpython/tool/cparser/cts.py
@@ -132,6 +132,8 @@ class CTypeSpace(object):
def realize_struct(self, struct):
type_name = struct.get_type_name()
+ if struct.fields is None:
+ raise ValueError('Missing definition for %s' % type_name)
entry = rffi_platform.Struct(type_name, struct.fields)
self._config_entries[entry] = struct.TYPE
return struct.TYPE
diff --git a/rpython/tool/cparser/test/test_cts.py b/rpython/tool/cparser/test/test_cts.py
index 59a06bcc02..48fd2beead 100644
--- a/rpython/tool/cparser/test/test_cts.py
+++ b/rpython/tool/cparser/test/test_cts.py
@@ -99,7 +99,6 @@ def test_multiple_sources():
Object = cts.definitions['Object']
assert Object.c_type.TO is Type
-@pytest.mark.xfail(reason='Should we support this?')
def test_incomplete():
cdef = """
typedef ssize_t Py_ssize_t;
@@ -116,9 +115,8 @@ def test_incomplete():
} Buffer;
"""
- cts = parse_source(cdef)
- Object = cts.gettype('Object')
- assert isinstance(Object, lltype.Struct)
+ with pytest.raises(ValueError):
+ parse_source(cdef)
def test_incomplete_struct():
cdef = """