Skip to content

Commit d83c9e3

Browse files
committed
Upgrade idna to 3.6
1 parent 14d949a commit d83c9e3

File tree

8 files changed

+277
-271
lines changed

8 files changed

+277
-271
lines changed

news/idna.vendor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade idna to 3.6

src/pip/_vendor/idna/LICENSE.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2013-2021, Kim Davies
3+
Copyright (c) 2013-2023, Kim Davies and contributors.
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without
7-
modification, are permitted provided that the following conditions are met:
7+
modification, are permitted provided that the following conditions are
8+
met:
89

9-
1. Redistributions of source code must retain the above copyright notice, this
10-
list of conditions and the following disclaimer.
10+
1. Redistributions of source code must retain the above copyright
11+
notice, this list of conditions and the following disclaimer.
1112

12-
2. Redistributions in binary form must reproduce the above copyright notice,
13-
this list of conditions and the following disclaimer in the documentation
14-
and/or other materials provided with the distribution.
13+
2. Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in the
15+
documentation and/or other materials provided with the distribution.
1516

1617
3. Neither the name of the copyright holder nor the names of its
1718
contributors may be used to endorse or promote products derived from
1819
this software without specific prior written permission.
1920

20-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

src/pip/_vendor/idna/codec.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .core import encode, decode, alabel, ulabel, IDNAError
22
import codecs
33
import re
4-
from typing import Tuple, Optional
4+
from typing import Any, Tuple, Optional
55

66
_unicode_dots_re = re.compile('[\u002e\u3002\uff0e\uff61]')
77

@@ -26,24 +26,24 @@ def decode(self, data: bytes, errors: str = 'strict') -> Tuple[str, int]:
2626
return decode(data), len(data)
2727

2828
class IncrementalEncoder(codecs.BufferedIncrementalEncoder):
29-
def _buffer_encode(self, data: str, errors: str, final: bool) -> Tuple[str, int]: # type: ignore
29+
def _buffer_encode(self, data: str, errors: str, final: bool) -> Tuple[bytes, int]:
3030
if errors != 'strict':
3131
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))
3232

3333
if not data:
34-
return "", 0
34+
return b'', 0
3535

3636
labels = _unicode_dots_re.split(data)
37-
trailing_dot = ''
37+
trailing_dot = b''
3838
if labels:
3939
if not labels[-1]:
40-
trailing_dot = '.'
40+
trailing_dot = b'.'
4141
del labels[-1]
4242
elif not final:
4343
# Keep potentially unfinished label until the next call
4444
del labels[-1]
4545
if labels:
46-
trailing_dot = '.'
46+
trailing_dot = b'.'
4747

4848
result = []
4949
size = 0
@@ -54,18 +54,21 @@ def _buffer_encode(self, data: str, errors: str, final: bool) -> Tuple[str, int]
5454
size += len(label)
5555

5656
# Join with U+002E
57-
result_str = '.'.join(result) + trailing_dot # type: ignore
57+
result_bytes = b'.'.join(result) + trailing_dot
5858
size += len(trailing_dot)
59-
return result_str, size
59+
return result_bytes, size
6060

6161
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
62-
def _buffer_decode(self, data: str, errors: str, final: bool) -> Tuple[str, int]: # type: ignore
62+
def _buffer_decode(self, data: Any, errors: str, final: bool) -> Tuple[str, int]:
6363
if errors != 'strict':
6464
raise IDNAError('Unsupported error handling \"{}\"'.format(errors))
6565

6666
if not data:
6767
return ('', 0)
6868

69+
if not isinstance(data, str):
70+
data = str(data, 'ascii')
71+
6972
labels = _unicode_dots_re.split(data)
7073
trailing_dot = ''
7174
if labels:
@@ -99,14 +102,17 @@ class StreamReader(Codec, codecs.StreamReader):
99102
pass
100103

101104

102-
def getregentry() -> codecs.CodecInfo:
103-
# Compatibility as a search_function for codecs.register()
105+
def search_function(name: str) -> Optional[codecs.CodecInfo]:
106+
if name != 'idna2008':
107+
return None
104108
return codecs.CodecInfo(
105-
name='idna',
106-
encode=Codec().encode, # type: ignore
107-
decode=Codec().decode, # type: ignore
109+
name=name,
110+
encode=Codec().encode,
111+
decode=Codec().decode,
108112
incrementalencoder=IncrementalEncoder,
109113
incrementaldecoder=IncrementalDecoder,
110114
streamwriter=StreamWriter,
111115
streamreader=StreamReader,
112116
)
117+
118+
codecs.register(search_function)

src/pip/_vendor/idna/core.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def uts46_remap(domain: str, std3_rules: bool = True, transitional: bool = False
318318
status = uts46row[1]
319319
replacement = None # type: Optional[str]
320320
if len(uts46row) == 3:
321-
replacement = uts46row[2] # type: ignore
321+
replacement = uts46row[2]
322322
if (status == 'V' or
323323
(status == 'D' and not transitional) or
324324
(status == '3' and not std3_rules and replacement is None)):
@@ -338,9 +338,9 @@ def uts46_remap(domain: str, std3_rules: bool = True, transitional: bool = False
338338

339339

340340
def encode(s: Union[str, bytes, bytearray], strict: bool = False, uts46: bool = False, std3_rules: bool = False, transitional: bool = False) -> bytes:
341-
if isinstance(s, (bytes, bytearray)):
341+
if not isinstance(s, str):
342342
try:
343-
s = s.decode('ascii')
343+
s = str(s, 'ascii')
344344
except UnicodeDecodeError:
345345
raise IDNAError('should pass a unicode string to the function rather than a byte string.')
346346
if uts46:
@@ -372,8 +372,8 @@ def encode(s: Union[str, bytes, bytearray], strict: bool = False, uts46: bool =
372372

373373
def decode(s: Union[str, bytes, bytearray], strict: bool = False, uts46: bool = False, std3_rules: bool = False) -> str:
374374
try:
375-
if isinstance(s, (bytes, bytearray)):
376-
s = s.decode('ascii')
375+
if not isinstance(s, str):
376+
s = str(s, 'ascii')
377377
except UnicodeDecodeError:
378378
raise IDNAError('Invalid ASCII in A-label')
379379
if uts46:

src/pip/_vendor/idna/idnadata.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is automatically generated by tools/idna-data
22

3-
__version__ = '15.0.0'
3+
__version__ = '15.1.0'
44
scripts = {
55
'Greek': (
66
0x37000000374,
@@ -59,6 +59,7 @@
5959
0x2b7400002b81e,
6060
0x2b8200002cea2,
6161
0x2ceb00002ebe1,
62+
0x2ebf00002ee5e,
6263
0x2f8000002fa1e,
6364
0x300000003134b,
6465
0x31350000323b0,
@@ -1834,7 +1835,6 @@
18341835
0xa7d50000a7d6,
18351836
0xa7d70000a7d8,
18361837
0xa7d90000a7da,
1837-
0xa7f20000a7f5,
18381838
0xa7f60000a7f8,
18391839
0xa7fa0000a828,
18401840
0xa82c0000a82d,
@@ -1907,9 +1907,7 @@
19071907
0x1060000010737,
19081908
0x1074000010756,
19091909
0x1076000010768,
1910-
0x1078000010786,
1911-
0x10787000107b1,
1912-
0x107b2000107bb,
1910+
0x1078000010781,
19131911
0x1080000010806,
19141912
0x1080800010809,
19151913
0x1080a00010836,
@@ -2134,6 +2132,7 @@
21342132
0x2b7400002b81e,
21352133
0x2b8200002cea2,
21362134
0x2ceb00002ebe1,
2135+
0x2ebf00002ee5e,
21372136
0x300000003134b,
21382137
0x31350000323b0,
21392138
),

src/pip/_vendor/idna/package_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = '3.4'
1+
__version__ = '3.6'
22

0 commit comments

Comments
 (0)