kjd / idna

Internationalized Domain Names for Python (IDNA 2008 and UTS #46)
BSD 3-Clause "New" or "Revised" License
248 stars 91 forks source link

Remove redundant steps in alabel() #152

Closed elliotwutingfeng closed 7 months ago

elliotwutingfeng commented 11 months ago

Proposed change

I found some portions of alabel() which are either unreachable or redundant.


if not label:
    raise IDNAError('No Input')

is not reachable because an empty string would be caught by ulabel(label_bytes) in the preceding try-block.


label = str(label)

is redundant as label is already a str, if it was not a str it would have been caught by the preceding try-block.


We can simplify label_bytes as _alabel_prefix + _punycode(label).