@@ -135,10 +135,10 @@ cdef inline int get_data_from_buffer(object obj,
135135 if view.itemsize != 1 :
136136 PyBuffer_Release(view)
137137 raise BufferError(" cannot unpack from multi-byte object" )
138- if PyBuffer_IsContiguous(view, ' A' ) == 0 :
138+ if PyBuffer_IsContiguous(view, b ' A' ) == 0 :
139139 PyBuffer_Release(view)
140140 # create a contiguous copy and get buffer
141- contiguous = PyMemoryView_GetContiguous(obj, PyBUF_READ, ' C' )
141+ contiguous = PyMemoryView_GetContiguous(obj, PyBUF_READ, b ' C' )
142142 PyObject_GetBuffer(contiguous, view, PyBUF_SIMPLE)
143143 # view must hold the only reference to contiguous,
144144 # so memory is freed when view is released
@@ -440,14 +440,11 @@ cdef class Unpacker(object):
440440 else :
441441 self .file_like = None
442442
443- cdef object _unpack(self , execute_fn execute, object write_bytes, bint iter = 0 ):
443+ cdef object _unpack(self , execute_fn execute, bint iter = 0 ):
444444 cdef int ret
445445 cdef object obj
446446 cdef Py_ssize_t prev_head
447447
448- if write_bytes is not None :
449- PyErr_WarnEx(DeprecationWarning , " `write_bytes` option is deprecated. Use `.tell()` instead." , 1 )
450-
451448 if self .buf_head >= self .buf_tail and self .file_like is not None :
452449 self .read_from_file()
453450
@@ -461,8 +458,6 @@ cdef class Unpacker(object):
461458
462459 ret = execute(& self .ctx, self .buf, self .buf_tail, & self .buf_head)
463460 self .stream_offset += self .buf_head - prev_head
464- if write_bytes is not None :
465- write_bytes(PyBytes_FromStringAndSize(self .buf + prev_head, self .buf_head - prev_head))
466461
467462 if ret == 1 :
468463 obj = unpack_data(& self .ctx)
@@ -489,41 +484,35 @@ cdef class Unpacker(object):
489484 ret += self .file_like.read(nbytes - len (ret))
490485 return ret
491486
492- def unpack (self , object write_bytes = None ):
487+ def unpack (self ):
493488 """ Unpack one object
494489
495- If write_bytes is not None, it will be called with parts of the raw
496- message as it is unpacked.
497-
498490 Raises `OutOfData` when there are no more bytes to unpack.
499491 """
500- return self ._unpack(unpack_construct, write_bytes )
492+ return self ._unpack(unpack_construct)
501493
502- def skip (self , object write_bytes = None ):
494+ def skip (self ):
503495 """ Read and ignore one object, returning None
504496
505- If write_bytes is not None, it will be called with parts of the raw
506- message as it is unpacked.
507-
508497 Raises `OutOfData` when there are no more bytes to unpack.
509498 """
510- return self ._unpack(unpack_skip, write_bytes )
499+ return self ._unpack(unpack_skip)
511500
512- def read_array_header (self , object write_bytes = None ):
501+ def read_array_header (self ):
513502 """ assuming the next object is an array, return its size n, such that
514503 the next n unpack() calls will iterate over its contents.
515504
516505 Raises `OutOfData` when there are no more bytes to unpack.
517506 """
518- return self ._unpack(read_array_header, write_bytes )
507+ return self ._unpack(read_array_header)
519508
520- def read_map_header (self , object write_bytes = None ):
509+ def read_map_header (self ):
521510 """ assuming the next object is a map, return its size n, such that the
522511 next n * 2 unpack() calls will iterate over its key-value pairs.
523512
524513 Raises `OutOfData` when there are no more bytes to unpack.
525514 """
526- return self ._unpack(read_map_header, write_bytes )
515+ return self ._unpack(read_map_header)
527516
528517 def tell (self ):
529518 return self .stream_offset
@@ -532,7 +521,7 @@ cdef class Unpacker(object):
532521 return self
533522
534523 def __next__ (self ):
535- return self ._unpack(unpack_construct, None , 1 )
524+ return self ._unpack(unpack_construct, 1 )
536525
537526 # for debug.
538527 # def _buf(self):
0 commit comments