@@ -135,10 +135,10 @@ cdef inline int get_data_from_buffer(object obj,
135
135
if view.itemsize != 1 :
136
136
PyBuffer_Release(view)
137
137
raise BufferError(" cannot unpack from multi-byte object" )
138
- if PyBuffer_IsContiguous(view, ' A' ) == 0 :
138
+ if PyBuffer_IsContiguous(view, b ' A' ) == 0 :
139
139
PyBuffer_Release(view)
140
140
# create a contiguous copy and get buffer
141
- contiguous = PyMemoryView_GetContiguous(obj, PyBUF_READ, ' C' )
141
+ contiguous = PyMemoryView_GetContiguous(obj, PyBUF_READ, b ' C' )
142
142
PyObject_GetBuffer(contiguous, view, PyBUF_SIMPLE)
143
143
# view must hold the only reference to contiguous,
144
144
# so memory is freed when view is released
@@ -440,14 +440,11 @@ cdef class Unpacker(object):
440
440
else :
441
441
self .file_like = None
442
442
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 ):
444
444
cdef int ret
445
445
cdef object obj
446
446
cdef Py_ssize_t prev_head
447
447
448
- if write_bytes is not None :
449
- PyErr_WarnEx(DeprecationWarning , " `write_bytes` option is deprecated. Use `.tell()` instead." , 1 )
450
-
451
448
if self .buf_head >= self .buf_tail and self .file_like is not None :
452
449
self .read_from_file()
453
450
@@ -461,8 +458,6 @@ cdef class Unpacker(object):
461
458
462
459
ret = execute(& self .ctx, self .buf, self .buf_tail, & self .buf_head)
463
460
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))
466
461
467
462
if ret == 1 :
468
463
obj = unpack_data(& self .ctx)
@@ -489,41 +484,35 @@ cdef class Unpacker(object):
489
484
ret += self .file_like.read(nbytes - len (ret))
490
485
return ret
491
486
492
- def unpack (self , object write_bytes = None ):
487
+ def unpack (self ):
493
488
""" Unpack one object
494
489
495
- If write_bytes is not None, it will be called with parts of the raw
496
- message as it is unpacked.
497
-
498
490
Raises `OutOfData` when there are no more bytes to unpack.
499
491
"""
500
- return self ._unpack(unpack_construct, write_bytes )
492
+ return self ._unpack(unpack_construct)
501
493
502
- def skip (self , object write_bytes = None ):
494
+ def skip (self ):
503
495
""" Read and ignore one object, returning None
504
496
505
- If write_bytes is not None, it will be called with parts of the raw
506
- message as it is unpacked.
507
-
508
497
Raises `OutOfData` when there are no more bytes to unpack.
509
498
"""
510
- return self ._unpack(unpack_skip, write_bytes )
499
+ return self ._unpack(unpack_skip)
511
500
512
- def read_array_header (self , object write_bytes = None ):
501
+ def read_array_header (self ):
513
502
""" assuming the next object is an array, return its size n, such that
514
503
the next n unpack() calls will iterate over its contents.
515
504
516
505
Raises `OutOfData` when there are no more bytes to unpack.
517
506
"""
518
- return self ._unpack(read_array_header, write_bytes )
507
+ return self ._unpack(read_array_header)
519
508
520
- def read_map_header (self , object write_bytes = None ):
509
+ def read_map_header (self ):
521
510
""" assuming the next object is a map, return its size n, such that the
522
511
next n * 2 unpack() calls will iterate over its key-value pairs.
523
512
524
513
Raises `OutOfData` when there are no more bytes to unpack.
525
514
"""
526
- return self ._unpack(read_map_header, write_bytes )
515
+ return self ._unpack(read_map_header)
527
516
528
517
def tell (self ):
529
518
return self .stream_offset
@@ -532,7 +521,7 @@ cdef class Unpacker(object):
532
521
return self
533
522
534
523
def __next__ (self ):
535
- return self ._unpack(unpack_construct, None , 1 )
524
+ return self ._unpack(unpack_construct, 1 )
536
525
537
526
# for debug.
538
527
# def _buf(self):
0 commit comments