|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 |
| -from warnings import warn |
4 |
| - |
5 | 3 | from w3lib._types import StrOrBytes
|
6 | 4 |
|
7 | 5 |
|
8 |
| -def str_to_unicode( |
9 |
| - text: StrOrBytes, encoding: str | None = None, errors: str = "strict" |
10 |
| -) -> str: |
11 |
| - warn( |
12 |
| - "The w3lib.utils.str_to_unicode function is deprecated and " |
13 |
| - "will be removed in a future release.", |
14 |
| - DeprecationWarning, |
15 |
| - stacklevel=2, |
16 |
| - ) |
17 |
| - if encoding is None: |
18 |
| - encoding = "utf-8" |
19 |
| - if isinstance(text, bytes): |
20 |
| - return text.decode(encoding, errors) |
21 |
| - return text |
22 |
| - |
23 |
| - |
24 |
| -def unicode_to_str( |
25 |
| - text: StrOrBytes, encoding: str | None = None, errors: str = "strict" |
26 |
| -) -> bytes: |
27 |
| - warn( |
28 |
| - "The w3lib.utils.unicode_to_str function is deprecated and " |
29 |
| - "will be removed in a future release.", |
30 |
| - DeprecationWarning, |
31 |
| - stacklevel=2, |
32 |
| - ) |
33 |
| - if encoding is None: |
34 |
| - encoding = "utf-8" |
35 |
| - if isinstance(text, str): |
36 |
| - return text.encode(encoding, errors) |
37 |
| - return text |
38 |
| - |
39 |
| - |
40 | 6 | def to_unicode(
|
41 | 7 | text: StrOrBytes, encoding: str | None = None, errors: str = "strict"
|
42 | 8 | ) -> str:
|
@@ -67,17 +33,3 @@ def to_bytes(
|
67 | 33 | if encoding is None:
|
68 | 34 | encoding = "utf-8"
|
69 | 35 | return text.encode(encoding, errors)
|
70 |
| - |
71 |
| - |
72 |
| -def to_native_str( |
73 |
| - text: StrOrBytes, encoding: str | None = None, errors: str = "strict" |
74 |
| -) -> str: |
75 |
| - """Return str representation of `text`""" |
76 |
| - warn( |
77 |
| - "The w3lib.utils.to_native_str function is deprecated and " |
78 |
| - "will be removed in a future release. Please use " |
79 |
| - "w3lib.utils.to_unicode instead.", |
80 |
| - DeprecationWarning, |
81 |
| - stacklevel=2, |
82 |
| - ) |
83 |
| - return to_unicode(text, encoding, errors) |
0 commit comments