Commit 4575a2f2 authored by Stefan Behnel's avatar Stefan Behnel

Fix exttype inheritance from builtin bytearray type.

Closes #2106.
parent 6704d23e
......@@ -135,6 +135,9 @@ Bugs fixed
* Cython no longer creates useless and incorrect ``PyInstanceMethod`` wrappers for
methods in Python 3. Patch by Jeroen Demeyer. (Github issue #2105)
* The builtin ``bytearray`` type could not be used as base type of cdef classes.
(Github issue #2106)
Other changes
-------------
......
......@@ -391,6 +391,8 @@ def init_builtin_types():
utility = builtin_utility_code.get(name)
if name == 'frozenset':
objstruct_cname = 'PySetObject'
elif name == 'bytearray':
objstruct_cname = 'PyByteArrayObject'
elif name == 'bool':
objstruct_cname = None
elif name == 'Exception':
......
......@@ -275,3 +275,15 @@ def bytearray_append(bytearray b, signed char c, int i, object o):
b.append(i)
b.append(o)
return b
cdef class BytearraySubtype(bytearray):
"""
>>> b = BytearraySubtype(b'abc')
>>> b._append(ord('x'))
>>> b.append(ord('y'))
>>> print(b.decode('ascii'))
abcxy
"""
def _append(self, x):
self.append(x)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment