mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-12-08 06:09:49 +00:00
fallback: Remove old buffer protocol support (#384)
This commit is contained in:
parent
9f4b2d53b7
commit
de320488ae
2 changed files with 5 additions and 19 deletions
|
|
@ -111,21 +111,7 @@ def _check_type_strict(obj, t, type=type, tuple=tuple):
|
|||
|
||||
|
||||
def _get_data_from_buffer(obj):
|
||||
try:
|
||||
view = memoryview(obj)
|
||||
except TypeError:
|
||||
# try to use legacy buffer protocol if 2.7, otherwise re-raise
|
||||
if PY2:
|
||||
view = memoryview(buffer(obj))
|
||||
warnings.warn(
|
||||
"using old buffer interface to unpack %s; "
|
||||
"this leads to unpacking errors if slicing is used and "
|
||||
"will be removed in a future version" % type(obj),
|
||||
RuntimeWarning,
|
||||
stacklevel=3,
|
||||
)
|
||||
else:
|
||||
raise
|
||||
view = memoryview(obj)
|
||||
if view.itemsize != 1:
|
||||
raise ValueError("cannot unpack from multi-byte object")
|
||||
return view
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue