Skip to content

Commit 67f535f

Browse files
authored
Use proper stacklevel for deprecation warnings
1 parent dd73010 commit 67f535f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

w3lib/util.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ def str_to_unicode(text, encoding=None, errors='strict'):
55
warn(
66
"The w3lib.utils.str_to_unicode function is deprecated and "
77
"will be removed in a future release.",
8-
DeprecationWarning
8+
DeprecationWarning,
9+
stacklevel=2,
910
)
1011
if encoding is None:
1112
encoding = 'utf-8'
@@ -17,7 +18,8 @@ def unicode_to_str(text, encoding=None, errors='strict'):
1718
warn(
1819
"The w3lib.utils.unicode_to_str function is deprecated and "
1920
"will be removed in a future release.",
20-
DeprecationWarning
21+
DeprecationWarning,
22+
stacklevel=2,
2123
)
2224
if encoding is None:
2325
encoding = 'utf-8'
@@ -55,6 +57,7 @@ def to_native_str(text, encoding=None, errors='strict'):
5557
"The w3lib.utils.to_native_str function is deprecated and "
5658
"will be removed in a future release. Please use "
5759
"w3lib.utils.to_unicode instead.",
58-
DeprecationWarning
60+
DeprecationWarning,
61+
stacklevel=2,
5962
)
6063
return to_unicode(text, encoding, errors)

0 commit comments

Comments
 (0)