Skip to content

Commit ef30fee

Browse files
committed
Remove dead code and pare back superfluous comments
1 parent b907913 commit ef30fee

6 files changed

Lines changed: 10 additions & 67 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ jobs:
5050
path: dist/
5151

5252
publish-to-pypi:
53-
name: >-
54-
Publish to PyPI
53+
name: Publish to PyPI
5554
if: startsWith(github.ref, 'refs/tags/v') # only publish to PyPI on version tag pushes
5655
needs:
5756
- build

‎.github/workflows/python-package.yml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
41
name: Python package
52

63
on:
@@ -75,7 +72,7 @@ jobs:
7572
gil: '0'
7673
- python-version: '3.15t-dev'
7774
gil: '0'
78-
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
75+
runs-on: ubuntu-latest
7976
steps:
8077
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
8178
- name: Set up Python ${{ matrix.python-version }}

‎idna/codec.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ def _buffer_encode(self, data: str, errors: str, final: bool) -> tuple[bytes, in
7575
size += 1
7676
size += len(label)
7777

78-
# Join with U+002E
7978
result_bytes = b".".join(result) + trailing_dot
8079
size += len(trailing_dot)
8180
return result_bytes, size

‎idna/core.py‎

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -662,31 +662,27 @@ def uts46_remap(domain: str, std3_rules: bool = True, transitional: bool = False
662662
if len(domain) > _max_input_length:
663663
raise IDNAError("Domain too long", code="input_too_long")
664664
if domain.isascii():
665-
# The only ASCII mapping in UTS #46 is upper- to lowercase; every
666-
# other ASCII codepoint has status V (tests pin this against the
667-
# table). ASCII is invariant under NFC, so this is the whole job.
665+
# The only ASCII mapping in UTS #46 is upper- to lowercase, and
666+
# ASCII is invariant under NFC, so lowercasing is the whole job.
668667
result = domain.lower()
669668
if std3_rules:
670669
_check_std3(result, domain, 0)
671670
return result
672671

673672
from .uts46data import uts46_replacements, uts46_starts, uts46_statuses
674673

675-
# Characters that pass through unchanged are not copied one at a time:
676-
# ``start`` marks the beginning of the current run of unchanged input,
677-
# and a run is only sliced out when a character has to be replaced or
678-
# dropped. For the common case where nothing changes no copy is made.
679-
# The STD3 check is applied to each piece of output as it is produced,
680-
# so that a violation is reported at its position in the input.
674+
# ``start`` marks the run of unchanged input not yet copied; a run is
675+
# only sliced out when a character must be replaced or dropped, so the
676+
# common no-change case makes no copy. STD3 is checked per output piece
677+
# to report a violation at its input position.
681678
output: list[str] = []
682679
start = 0
683680
for pos, char in enumerate(domain):
684681
code_point = ord(char)
685682
i = code_point if code_point < 256 else bisect.bisect_right(uts46_starts, code_point) - 1
686683
status = uts46_statuses[i]
687-
# UTS #46 §4: V is always valid, D is deviation (kept: transitional
688-
# processing, which mapped it, is deprecated), M is mapped, I is
689-
# ignored, anything else is disallowed.
684+
# UTS #46 §4: V valid, D deviation (kept), M mapped, I ignored,
685+
# anything else disallowed.
690686
if status == _STATUS_VALID:
691687
continue
692688
if status == _STATUS_MAPPED:
@@ -773,8 +769,6 @@ def encode(
773769
if uts46:
774770
s = uts46_remap(s, std3_rules)
775771

776-
# Reject inputs that exceed the maximum DNS domain length up-front
777-
# to avoid expensive computation on long inputs.
778772
if not valid_string_length(s, trailing_dot=True):
779773
raise IDNAError("Domain too long", code="domain_too_long")
780774

@@ -840,8 +834,6 @@ def decode(
840834
raise IDNAError("Domain too long", code="input_too_long")
841835
if uts46:
842836
s = uts46_remap(s, std3_rules, False)
843-
# Reject inputs that exceed the maximum DNS domain length up-front
844-
# to avoid expensive computation on long inputs.
845837
if not valid_string_length(s, trailing_dot=True):
846838
raise IDNAError("Domain too long", code="domain_too_long")
847839
trailing_dot = False

‎tests/test_idna.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def test_check_bidi(self):
138138

139139
# RFC 5893 Rule 2
140140
self.assertTrue(idna.check_bidi(r + al))
141-
self.assertTrue(idna.check_bidi(r + al))
142141
self.assertTrue(idna.check_bidi(r + an))
143142
self.assertTrue(idna.check_bidi(r + en))
144143
self.assertTrue(idna.check_bidi(r + es + al))

‎tools/idna-data‎

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -826,44 +826,6 @@ def uts46_tests(ucdata):
826826
yield ""
827827

828828

829-
"""
830-
try:
831-
output = idna.decode(source, uts46=True, strict=True)
832-
if to_unicode_status != "[]":
833-
self.fail("decode() did not emit required error {} for {}".format(to_unicode, repr(source)))
834-
self.assertEqual(output, to_unicode, "unexpected decode() output")
835-
except (idna.IDNAError, UnicodeError, ValueError) as exc:
836-
if str(exc).startswith("Unknown"):
837-
raise unittest.SkipTest("Test requires support for a newer version of Unicode than this Python supports")
838-
if to_unicode_status == "[]":
839-
raise
840-
841-
try:
842-
output = idna.encode(source, uts46=True, strict=True).decode("ascii")
843-
if to_ascii_status != "[]":
844-
self.fail("encode() did not emit required error {} for {}".format(to_ascii_status, repr(source)))
845-
self.assertEqual(output, to_ascii, "unexpected encode() output")
846-
except (idna.IDNAError, UnicodeError, ValueError) as exc:
847-
if str(exc).startswith("Unknown"):
848-
raise unittest.SkipTest("Test requires support for a newer version of Unicode than this Python supports")
849-
if to_ascii_status == "[]":
850-
raise
851-
852-
try:
853-
output = idna.encode(source, uts46=True, strict=True, transitional=True).decode("ascii")
854-
if to_ascii_t_status != "[]":
855-
self.fail(
856-
"encode(transitional=True) did not emit required error {} for {}".format(to_ascii_t_status, repr(source))
857-
)
858-
self.assertEqual(output, to_ascii_t, "unexpected encode() output")
859-
except (idna.IDNAError, UnicodeError, ValueError) as exc:
860-
if str(exc).startswith("Unknown"):
861-
raise unittest.SkipTest("Test requires support for a newer version of Unicode than this Python supports")
862-
if to_ascii_t_status == "[]":
863-
raise
864-
"""
865-
866-
867829
def make_libdata(args, ucdata):
868830
dest_dir = args.dir or "."
869831
test_dir = args.test_dir or dest_dir
@@ -902,11 +864,6 @@ def main():
902864
parser.add_argument("--test-dir", type=str, default=None, help="Where to export test files (defaults to --dir)")
903865
parser.add_argument("--cache", type=str, default=None, help="Where to cache Unicode data")
904866
parser.add_argument("--no-cache", action="store_true", help="Don't cache Unicode data")
905-
libdata = parser.add_argument_group("make-libdata", "Make module data for Python IDNA library")
906-
907-
tables = parser.add_argument_group("make-table", "Make IANA-style reference table")
908-
909-
codepoint = parser.add_argument_group("codepoint", "Display related data for given codepoint (e.g. U+0061)")
910867

911868
args = parser.parse_args()
912869

0 commit comments

Comments
 (0)