fallback: Fix warning stacklevel (#327)

This commit is contained in:
INADA Naoki 2018-11-14 16:34:51 +09:00 committed by GitHub
parent 39f8aa78c7
commit 2b5f59166b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,7 +89,7 @@ def _get_data_from_buffer(obj):
warnings.warn("using old buffer interface to unpack %s; " warnings.warn("using old buffer interface to unpack %s; "
"this leads to unpacking errors if slicing is used and " "this leads to unpacking errors if slicing is used and "
"will be removed in a future version" % type(obj), "will be removed in a future version" % type(obj),
RuntimeWarning) RuntimeWarning, stacklevel=3)
else: else:
raise raise
if view.itemsize != 1: if view.itemsize != 1:
@ -100,7 +100,7 @@ def _get_data_from_buffer(obj):
def unpack(stream, **kwargs): def unpack(stream, **kwargs):
warnings.warn( warnings.warn(
"Direct calling implementation's unpack() is deprecated, Use msgpack.unpack() or unpackb() instead.", "Direct calling implementation's unpack() is deprecated, Use msgpack.unpack() or unpackb() instead.",
DeprecationWarning) DeprecationWarning, stacklevel=2)
data = stream.read() data = stream.read()
return unpackb(data, **kwargs) return unpackb(data, **kwargs)
@ -226,7 +226,7 @@ class Unpacker(object):
if encoding is not None: if encoding is not None:
warnings.warn( warnings.warn(
"encoding is deprecated, Use raw=False instead.", "encoding is deprecated, Use raw=False instead.",
DeprecationWarning) DeprecationWarning, stacklevel=2)
if unicode_errors is None: if unicode_errors is None:
unicode_errors = 'strict' unicode_errors = 'strict'
@ -712,7 +712,7 @@ class Packer(object):
else: else:
warnings.warn( warnings.warn(
"encoding is deprecated, Use raw=False instead.", "encoding is deprecated, Use raw=False instead.",
DeprecationWarning) DeprecationWarning, stacklevel=2)
if unicode_errors is None: if unicode_errors is None:
unicode_errors = 'strict' unicode_errors = 'strict'