@@ -31,8 +31,7 @@ from .crc cimport crc32_gzip_refl
31
31
from .igzip_lib cimport *
32
32
from libc.stdint cimport UINT64_MAX, UINT32_MAX
33
33
from cpython.mem cimport PyMem_Malloc, PyMem_Realloc, PyMem_Free
34
- from cpython.buffer cimport PyBUF_READ, PyBUF_C_CONTIGUOUS, PyObject_GetBuffer, \
35
- PyBuffer_Release
34
+ from cpython.buffer cimport PyBUF_SIMPLE, PyObject_GetBuffer, PyBuffer_Release
36
35
from cpython.bytes cimport PyBytes_FromStringAndSize
37
36
from cpython.long cimport PyLong_AsUnsignedLongMask
38
37
@@ -97,7 +96,7 @@ def adler32(data, value = 1):
97
96
cdef unsigned long init = PyLong_AsUnsignedLongMask(value)
98
97
cdef Py_buffer buffer_data
99
98
cdef Py_buffer* buffer = & buffer_data
100
- if PyObject_GetBuffer(data, buffer , PyBUF_READ & PyBUF_C_CONTIGUOUS ) != 0 :
99
+ if PyObject_GetBuffer(data, buffer , PyBUF_SIMPLE ) != 0 :
101
100
raise TypeError (" Failed to get buffer" )
102
101
try :
103
102
if buffer .len > UINT64_MAX:
@@ -117,7 +116,7 @@ def crc32(data, value = 0):
117
116
cdef unsigned long init = PyLong_AsUnsignedLongMask(value)
118
117
cdef Py_buffer buffer_data
119
118
cdef Py_buffer* buffer = & buffer_data
120
- if PyObject_GetBuffer(data, buffer , PyBUF_READ & PyBUF_C_CONTIGUOUS ) != 0 :
119
+ if PyObject_GetBuffer(data, buffer , PyBUF_SIMPLE ) != 0 :
121
120
raise TypeError (" Failed to get buffer" )
122
121
try :
123
122
if buffer .len > UINT64_MAX:
@@ -218,7 +217,7 @@ def compress(data,
218
217
# initialise input
219
218
cdef Py_buffer buffer_data
220
219
cdef Py_buffer* buffer = & buffer_data
221
- if PyObject_GetBuffer(data, buffer , PyBUF_READ & PyBUF_C_CONTIGUOUS ) != 0 :
220
+ if PyObject_GetBuffer(data, buffer , PyBUF_SIMPLE ) != 0 :
222
221
raise TypeError (" Failed to get buffer" )
223
222
cdef Py_ssize_t ibuflen = buffer .len
224
223
cdef unsigned char * ibuf = < unsigned char * > buffer .buf
@@ -295,7 +294,7 @@ def decompress(data,
295
294
# initialise input
296
295
cdef Py_buffer buffer_data
297
296
cdef Py_buffer* buffer = & buffer_data
298
- if PyObject_GetBuffer(data, buffer , PyBUF_READ & PyBUF_C_CONTIGUOUS ) != 0 :
297
+ if PyObject_GetBuffer(data, buffer , PyBUF_SIMPLE ) != 0 :
299
298
raise TypeError (" Failed to get buffer" )
300
299
cdef Py_ssize_t ibuflen = buffer .len
301
300
cdef unsigned char * ibuf = < unsigned char * > buffer .buf
@@ -439,7 +438,7 @@ cdef class Compress:
439
438
# initialise input
440
439
cdef Py_buffer buffer_data
441
440
cdef Py_buffer* buffer = & buffer_data
442
- if PyObject_GetBuffer(data, buffer , PyBUF_READ & PyBUF_C_CONTIGUOUS ) != 0 :
441
+ if PyObject_GetBuffer(data, buffer , PyBUF_SIMPLE ) != 0 :
443
442
raise TypeError (" Failed to get buffer" )
444
443
cdef Py_ssize_t ibuflen = buffer .len
445
444
cdef unsigned char * ibuf = < unsigned char * > buffer .buf
@@ -618,7 +617,7 @@ cdef class Decompress:
618
617
# initialise input
619
618
cdef Py_buffer buffer_data
620
619
cdef Py_buffer* buffer = & buffer_data
621
- if PyObject_GetBuffer(data, buffer , PyBUF_READ & PyBUF_C_CONTIGUOUS ) != 0 :
620
+ if PyObject_GetBuffer(data, buffer , PyBUF_SIMPLE ) != 0 :
622
621
raise TypeError (" Failed to get buffer" )
623
622
cdef Py_ssize_t ibuflen = buffer .len
624
623
cdef unsigned char * ibuf = < unsigned char * > buffer .buf
@@ -674,7 +673,7 @@ cdef class Decompress:
674
673
675
674
cdef Py_buffer buffer_data
676
675
cdef Py_buffer* buffer = & buffer_data
677
- if PyObject_GetBuffer(self .unconsumed_tail, buffer , PyBUF_READ & PyBUF_C_CONTIGUOUS ) != 0 :
676
+ if PyObject_GetBuffer(self .unconsumed_tail, buffer , PyBUF_SIMPLE ) != 0 :
678
677
raise TypeError (" Failed to get buffer" )
679
678
cdef Py_ssize_t ibuflen = buffer .len
680
679
cdef unsigned char * ibuf = < unsigned char * > buffer .buf
0 commit comments