if char is not None:
# Can use direct comparison
code = dedent("""\
+ if (*ts == '1') ++ts;
if (*ts != '%s') {
PyErr_Format(PyExc_ValueError, "Buffer datatype mismatch (rejecting on '%%s')", ts);
return NULL;
ctype = dtype.declaration_code("")
code = dedent("""\
int ok;
+ if (*ts == '1') ++ts;
switch (*ts) {""", 2)
if dtype.is_int:
types = [
(<short*>buf)[0] = <short>value
return 0
cdef get_itemsize(self): return sizeof(short)
- cdef get_default_format(self): return "=h"
+ cdef get_default_format(self): return "h" # Try without endian specifier
cdef class UnsignedShortMockBuffer(MockBuffer):
cdef int write(self, char* buf, object value) except -1:
(<unsigned short*>buf)[0] = <unsigned short>value
return 0
cdef get_itemsize(self): return sizeof(unsigned short)
- cdef get_default_format(self): return "=H"
+ cdef get_default_format(self): return "=1H" # Try with repeat count
cdef extern from *:
void* addr_of_pyobject "(void*)"(object)