equal
deleted
inserted
replaced
7 |
7 |
8 |
8 |
9 import locale |
9 import locale |
10 import os |
10 import os |
11 import re |
11 import re |
|
12 import typing |
12 import unicodedata |
13 import unicodedata |
|
14 |
|
15 from typing import ( |
|
16 Any, |
|
17 Callable, |
|
18 List, |
|
19 Text, |
|
20 Type, |
|
21 TypeVar, |
|
22 Union, |
|
23 ) |
13 |
24 |
14 from . import ( |
25 from . import ( |
15 error, |
26 error, |
16 policy, |
27 policy, |
17 pycompat, |
28 pycompat, |
18 ) |
29 ) |
19 |
30 |
20 from .pure import charencode as charencodepure |
31 from .pure import charencode as charencodepure |
21 |
32 |
22 if pycompat.TYPE_CHECKING: |
33 # keep pyflakes happy |
23 from typing import ( |
34 for t in (Any, Callable, List, Text, Type, Union): |
24 Any, |
35 assert t |
25 Callable, |
36 |
26 List, |
37 _Tlocalstr = TypeVar('_Tlocalstr', bound='localstr') |
27 Text, |
|
28 Type, |
|
29 TypeVar, |
|
30 Union, |
|
31 ) |
|
32 |
|
33 # keep pyflakes happy |
|
34 for t in (Any, Callable, List, Text, Type, Union): |
|
35 assert t |
|
36 |
|
37 _Tlocalstr = TypeVar('_Tlocalstr', bound='localstr') |
|
38 |
38 |
39 charencode = policy.importmod('charencode') |
39 charencode = policy.importmod('charencode') |
40 |
40 |
41 isasciistr = charencode.isasciistr |
41 isasciistr = charencode.isasciistr |
42 asciilower = charencode.asciilower |
42 asciilower = charencode.asciilower |
129 def __new__(cls, u, l): |
129 def __new__(cls, u, l): |
130 s = bytes.__new__(cls, l) |
130 s = bytes.__new__(cls, l) |
131 s._utf8 = u |
131 s._utf8 = u |
132 return s |
132 return s |
133 |
133 |
134 if pycompat.TYPE_CHECKING: |
134 if typing.TYPE_CHECKING: |
135 # pseudo implementation to help pytype see localstr() constructor |
135 # pseudo implementation to help pytype see localstr() constructor |
136 def __init__(self, u, l): |
136 def __init__(self, u, l): |
137 # type: (bytes, bytes) -> None |
137 # type: (bytes, bytes) -> None |
138 super(localstr, self).__init__(l) |
138 super(localstr, self).__init__(l) |
139 self._utf8 = u |
139 self._utf8 = u |