This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Vikram Hegde
Recipients Vikram Hegde
Date 2017-06-04.15:49:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496591394.26.0.00653153658066.issue30566@psf.upfronthosting.co.za>
In-reply-to
Content
Here is the relevant code snippet from  decode_generalized_number() in punycode.py

    try:
            char = ord(extended[extpos])
        except IndexError:
            if errors == "strict":
                raise UnicodeError("incomplete punicode string")
            return extpos + 1, None
        extpos += 1
        if 0x41 <= char <= 0x5A: # A-Z
            digit = char - 0x41
        elif 0x30 <= char <= 0x39:
            digit = char - 22 # 0x30-26
        elif errors == "strict":
            raise UnicodeError("Invalid extended code point '%s'"
                               % extended[extpos])

   While raising the UnicodeError() in the last line above, it accesses extended[extpos]. However extpos was incremented by 1 a few lines above that. This causes two errors:
   1) The UnicodeError() prints the wrong character (the one after the character we want)
   2) If the previous extpos was the last character in the string, then attempting to print character at extpos+1 will raise an IndexError.
History
Date User Action Args
2017-06-04 15:49:54Vikram Hegdesetrecipients: + Vikram Hegde
2017-06-04 15:49:54Vikram Hegdesetmessageid: <1496591394.26.0.00653153658066.issue30566@psf.upfronthosting.co.za>
2017-06-04 15:49:54Vikram Hegdelinkissue30566 messages
2017-06-04 15:49:54Vikram Hegdecreate