[pypy-commit] pypy stdlib-2.7.13: Fix for test_abstract in ctypes/test/test_frombuffer
arigo
pypy.commits at gmail.com
Sun Dec 18 11:52:42 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: stdlib-2.7.13
Changeset: r89152:a7b53ded27c6
Date: 2016-12-18 17:51 +0100
http://bitbucket.org/pypy/pypy/changeset/a7b53ded27c6/
Log: Fix for test_abstract in ctypes/test/test_frombuffer
diff --git a/lib_pypy/_ctypes/array.py b/lib_pypy/_ctypes/array.py
--- a/lib_pypy/_ctypes/array.py
+++ b/lib_pypy/_ctypes/array.py
@@ -67,6 +67,8 @@
from_address = cdata_from_address
def _sizeofinstances(self):
+ if self._ffiarray is None:
+ raise TypeError("abstract class")
size, alignment = self._ffiarray.size_alignment(self._length_)
return size
diff --git a/lib_pypy/_ctypes/structure.py b/lib_pypy/_ctypes/structure.py
--- a/lib_pypy/_ctypes/structure.py
+++ b/lib_pypy/_ctypes/structure.py
@@ -229,8 +229,10 @@
__metaclass__ = StructOrUnionMeta
def __new__(cls, *args, **kwds):
+ from _ctypes import union
self = super(_CData, cls).__new__(cls)
- if '_abstract_' in cls.__dict__:
+ if ('_abstract_' in cls.__dict__ or cls is Structure
+ or cls is union.Union):
raise TypeError("abstract class")
if hasattr(cls, '_ffistruct_'):
self.__dict__['_buffer'] = self._ffistruct_(autofree=True)
More information about the pypy-commit
mailing list