update windows build to Python 3.7
This commit is contained in:
parent
73105fa71e
commit
ddc59ab92d
5761 changed files with 750298 additions and 213405 deletions
|
|
@ -1 +1,2 @@
|
|||
from .package_data import __version__
|
||||
from .core import *
|
||||
|
|
|
|||
BIN
Lib/site-packages/idna/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
Lib/site-packages/idna/__pycache__/__init__.cpython-37.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/idna/__pycache__/codec.cpython-37.pyc
Normal file
BIN
Lib/site-packages/idna/__pycache__/codec.cpython-37.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/idna/__pycache__/compat.cpython-37.pyc
Normal file
BIN
Lib/site-packages/idna/__pycache__/compat.cpython-37.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/idna/__pycache__/core.cpython-37.pyc
Normal file
BIN
Lib/site-packages/idna/__pycache__/core.cpython-37.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/idna/__pycache__/idnadata.cpython-37.pyc
Normal file
BIN
Lib/site-packages/idna/__pycache__/idnadata.cpython-37.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/idna/__pycache__/intranges.cpython-37.pyc
Normal file
BIN
Lib/site-packages/idna/__pycache__/intranges.cpython-37.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/idna/__pycache__/package_data.cpython-37.pyc
Normal file
BIN
Lib/site-packages/idna/__pycache__/package_data.cpython-37.pyc
Normal file
Binary file not shown.
BIN
Lib/site-packages/idna/__pycache__/uts46data.cpython-37.pyc
Normal file
BIN
Lib/site-packages/idna/__pycache__/uts46data.cpython-37.pyc
Normal file
Binary file not shown.
|
|
@ -1,4 +1,4 @@
|
|||
from idna.core import encode, decode, alabel, ulabel, IDNAError
|
||||
from .core import encode, decode, alabel, ulabel, IDNAError
|
||||
import codecs
|
||||
import re
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from idna.core import *
|
||||
from idna.codec import *
|
||||
from .core import *
|
||||
from .codec import *
|
||||
|
||||
def ToASCII(label):
|
||||
return encode(label)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import bisect
|
|||
import unicodedata
|
||||
import re
|
||||
import sys
|
||||
from .intranges import intranges_contain
|
||||
|
||||
_virama_combining_class = 9
|
||||
_alabel_prefix = b'xn--'
|
||||
|
|
@ -33,10 +34,14 @@ class InvalidCodepointContext(IDNAError):
|
|||
|
||||
|
||||
def _combining_class(cp):
|
||||
return unicodedata.combining(unichr(cp))
|
||||
v = unicodedata.combining(unichr(cp))
|
||||
if v == 0:
|
||||
if not unicodedata.name(unichr(cp)):
|
||||
raise ValueError("Unknown character in unicodedata")
|
||||
return v
|
||||
|
||||
def _is_script(cp, script):
|
||||
return ord(cp) in idnadata.scripts[script]
|
||||
return intranges_contain(ord(cp), idnadata.scripts[script])
|
||||
|
||||
def _punycode(s):
|
||||
return s.encode('punycode')
|
||||
|
|
@ -70,7 +75,6 @@ def check_bidi(label, check_ltr=False):
|
|||
raise IDNABidiError('Unknown directionality in label {0} at position {1}'.format(repr(label), idx))
|
||||
if direction in ['R', 'AL', 'AN']:
|
||||
bidi_label = True
|
||||
break
|
||||
if not bidi_label and not check_ltr:
|
||||
return True
|
||||
|
||||
|
|
@ -155,9 +159,9 @@ def valid_contextj(label, pos):
|
|||
ok = False
|
||||
for i in range(pos-1, -1, -1):
|
||||
joining_type = idnadata.joining_types.get(ord(label[i]))
|
||||
if joining_type == 'T':
|
||||
if joining_type == ord('T'):
|
||||
continue
|
||||
if joining_type in ['L', 'D']:
|
||||
if joining_type in [ord('L'), ord('D')]:
|
||||
ok = True
|
||||
break
|
||||
|
||||
|
|
@ -167,9 +171,9 @@ def valid_contextj(label, pos):
|
|||
ok = False
|
||||
for i in range(pos+1, len(label)):
|
||||
joining_type = idnadata.joining_types.get(ord(label[i]))
|
||||
if joining_type == 'T':
|
||||
if joining_type == ord('T'):
|
||||
continue
|
||||
if joining_type in ['R', 'D']:
|
||||
if joining_type in [ord('R'), ord('D')]:
|
||||
ok = True
|
||||
break
|
||||
return ok
|
||||
|
|
@ -210,9 +214,9 @@ def valid_contexto(label, pos, exception=False):
|
|||
for cp in label:
|
||||
if cp == u'\u30fb':
|
||||
continue
|
||||
if not _is_script(cp, 'Hiragana') and not _is_script(cp, 'Katakana') and not _is_script(cp, 'Han'):
|
||||
return False
|
||||
return True
|
||||
if _is_script(cp, 'Hiragana') or _is_script(cp, 'Katakana') or _is_script(cp, 'Han'):
|
||||
return True
|
||||
return False
|
||||
|
||||
elif 0x660 <= cp_value <= 0x669:
|
||||
for cp in label:
|
||||
|
|
@ -240,12 +244,17 @@ def check_label(label):
|
|||
|
||||
for (pos, cp) in enumerate(label):
|
||||
cp_value = ord(cp)
|
||||
if cp_value in idnadata.codepoint_classes['PVALID']:
|
||||
if intranges_contain(cp_value, idnadata.codepoint_classes['PVALID']):
|
||||
continue
|
||||
elif cp_value in idnadata.codepoint_classes['CONTEXTJ']:
|
||||
if not valid_contextj(label, pos):
|
||||
raise InvalidCodepointContext('Joiner {0} not allowed at position {1} in {2}'.format(_unot(cp_value), pos+1, repr(label)))
|
||||
elif cp_value in idnadata.codepoint_classes['CONTEXTO']:
|
||||
elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTJ']):
|
||||
try:
|
||||
if not valid_contextj(label, pos):
|
||||
raise InvalidCodepointContext('Joiner {0} not allowed at position {1} in {2}'.format(
|
||||
_unot(cp_value), pos+1, repr(label)))
|
||||
except ValueError:
|
||||
raise IDNAError('Unknown codepoint adjacent to joiner {0} at position {1} in {2}'.format(
|
||||
_unot(cp_value), pos+1, repr(label)))
|
||||
elif intranges_contain(cp_value, idnadata.codepoint_classes['CONTEXTO']):
|
||||
if not valid_contexto(label, pos):
|
||||
raise InvalidCodepointContext('Codepoint {0} not allowed at position {1} in {2}'.format(_unot(cp_value), pos+1, repr(label)))
|
||||
else:
|
||||
|
|
@ -258,14 +267,11 @@ def alabel(label):
|
|||
|
||||
try:
|
||||
label = label.encode('ascii')
|
||||
try:
|
||||
ulabel(label)
|
||||
except:
|
||||
raise IDNAError('The label {0} is not a valid A-label'.format(label))
|
||||
ulabel(label)
|
||||
if not valid_label_length(label):
|
||||
raise IDNAError('Label too long')
|
||||
return label
|
||||
except UnicodeError:
|
||||
except UnicodeEncodeError:
|
||||
pass
|
||||
|
||||
if not label:
|
||||
|
|
@ -287,7 +293,7 @@ def ulabel(label):
|
|||
if not isinstance(label, (bytes, bytearray)):
|
||||
try:
|
||||
label = label.encode('ascii')
|
||||
except UnicodeError:
|
||||
except UnicodeEncodeError:
|
||||
check_label(label)
|
||||
return label
|
||||
|
||||
|
|
@ -316,10 +322,10 @@ def uts46_remap(domain, std3_rules=True, transitional=False):
|
|||
replacement = uts46row[2] if len(uts46row) == 3 else None
|
||||
if (status == "V" or
|
||||
(status == "D" and not transitional) or
|
||||
(status == "3" and std3_rules and replacement is None)):
|
||||
(status == "3" and not std3_rules and replacement is None)):
|
||||
output += char
|
||||
elif replacement is not None and (status == "M" or
|
||||
(status == "3" and std3_rules) or
|
||||
(status == "3" and not std3_rules) or
|
||||
(status == "D" and transitional)):
|
||||
output += replacement
|
||||
elif status != "I":
|
||||
|
|
@ -343,15 +349,17 @@ def encode(s, strict=False, uts46=False, std3_rules=False, transitional=False):
|
|||
labels = s.split('.')
|
||||
else:
|
||||
labels = _unicode_dots_re.split(s)
|
||||
while labels and not labels[0]:
|
||||
del labels[0]
|
||||
if not labels:
|
||||
if not labels or labels == ['']:
|
||||
raise IDNAError('Empty domain')
|
||||
if labels[-1] == '':
|
||||
del labels[-1]
|
||||
trailing_dot = True
|
||||
for label in labels:
|
||||
result.append(alabel(label))
|
||||
s = alabel(label)
|
||||
if s:
|
||||
result.append(s)
|
||||
else:
|
||||
raise IDNAError('Empty label')
|
||||
if trailing_dot:
|
||||
result.append(b'')
|
||||
s = b'.'.join(result)
|
||||
|
|
@ -372,15 +380,17 @@ def decode(s, strict=False, uts46=False, std3_rules=False):
|
|||
labels = _unicode_dots_re.split(s)
|
||||
else:
|
||||
labels = s.split(u'.')
|
||||
while labels and not labels[0]:
|
||||
del labels[0]
|
||||
if not labels:
|
||||
if not labels or labels == ['']:
|
||||
raise IDNAError('Empty domain')
|
||||
if not labels[-1]:
|
||||
del labels[-1]
|
||||
trailing_dot = True
|
||||
for label in labels:
|
||||
result.append(ulabel(label))
|
||||
s = ulabel(label)
|
||||
if s:
|
||||
result.append(s)
|
||||
else:
|
||||
raise IDNAError('Empty label')
|
||||
if trailing_dot:
|
||||
result.append(u'')
|
||||
return u'.'.join(result)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
53
Lib/site-packages/idna/intranges.py
Normal file
53
Lib/site-packages/idna/intranges.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
"""
|
||||
Given a list of integers, made up of (hopefully) a small number of long runs
|
||||
of consecutive integers, compute a representation of the form
|
||||
((start1, end1), (start2, end2) ...). Then answer the question "was x present
|
||||
in the original list?" in time O(log(# runs)).
|
||||
"""
|
||||
|
||||
import bisect
|
||||
|
||||
def intranges_from_list(list_):
|
||||
"""Represent a list of integers as a sequence of ranges:
|
||||
((start_0, end_0), (start_1, end_1), ...), such that the original
|
||||
integers are exactly those x such that start_i <= x < end_i for some i.
|
||||
|
||||
Ranges are encoded as single integers (start << 32 | end), not as tuples.
|
||||
"""
|
||||
|
||||
sorted_list = sorted(list_)
|
||||
ranges = []
|
||||
last_write = -1
|
||||
for i in range(len(sorted_list)):
|
||||
if i+1 < len(sorted_list):
|
||||
if sorted_list[i] == sorted_list[i+1]-1:
|
||||
continue
|
||||
current_range = sorted_list[last_write+1:i+1]
|
||||
ranges.append(_encode_range(current_range[0], current_range[-1] + 1))
|
||||
last_write = i
|
||||
|
||||
return tuple(ranges)
|
||||
|
||||
def _encode_range(start, end):
|
||||
return (start << 32) | end
|
||||
|
||||
def _decode_range(r):
|
||||
return (r >> 32), (r & ((1 << 32) - 1))
|
||||
|
||||
|
||||
def intranges_contain(int_, ranges):
|
||||
"""Determine if `int_` falls into one of the ranges in `ranges`."""
|
||||
tuple_ = _encode_range(int_, 0)
|
||||
pos = bisect.bisect_left(ranges, tuple_)
|
||||
# we could be immediately ahead of a tuple (start, end)
|
||||
# with start < int_ <= end
|
||||
if pos > 0:
|
||||
left, right = _decode_range(ranges[pos-1])
|
||||
if left <= int_ < right:
|
||||
return True
|
||||
# or we could be immediately behind a tuple (int_, end)
|
||||
if pos < len(ranges):
|
||||
left, _ = _decode_range(ranges[pos])
|
||||
if left == int_:
|
||||
return True
|
||||
return False
|
||||
2
Lib/site-packages/idna/package_data.py
Normal file
2
Lib/site-packages/idna/package_data.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
__version__ = '2.8'
|
||||
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue