Giter VIP home page Giter VIP logo

Comments (5)

jribbens avatar jribbens commented on September 27, 2024

It looks like it's because the except UnicodeError on line 269 of core.py is intended to be catching only exceptions from line 261 label = label.encode('ascii') but is also catching the perfectly good error message idna.core.InvalidCodepoint: Codepoint U+0020 at position 4 of 'foo bar' not allowed that is being thrown by ulabel because InvalidCodepoint is an indirect subclass of UnicodeError.

This bug is therefore already fixed by ebefacd which made IDNAError not be a subclass of UnicodeError anymore.

from idna.

kjd avatar kjd commented on September 27, 2024

Thanks for taking a look @jribbens !

from idna.

joernheissler avatar joernheissler commented on September 27, 2024

Okay, so I tried the latest version.

$ python3 foo.py
Traceback (most recent call last):
  File "/home/joern/idna/lib/python3.5/site-packages/idna-2.2-py3.5.egg/idna/core.py", line 263, in alabel
  File "/home/joern/idna/lib/python3.5/site-packages/idna-2.2-py3.5.egg/idna/core.py", line 299, in ulabel
  File "/home/joern/idna/lib/python3.5/site-packages/idna-2.2-py3.5.egg/idna/core.py", line 253, in check_label
idna.core.InvalidCodepoint: Codepoint U+0020 at position 4 of 'foo bar' not allowed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "foo.py", line 2, in <module>
    idna.encode(b'foo bar')
  File "/home/joern/idna/lib/python3.5/site-packages/idna-2.2-py3.5.egg/idna/core.py", line 355, in encode
  File "/home/joern/idna/lib/python3.5/site-packages/idna-2.2-py3.5.egg/idna/core.py", line 265, in alabel
idna.core.IDNAError: The label b'foo bar' is not a valid A-label

The "good" exception is now visible. But what's with the second? :)

from idna.

jribbens avatar jribbens commented on September 27, 2024

It's the appalling way Python 3 reports exceptions. ulabel throws the first exception listed above, which is caught by line 264 in alabel and the second exception is thrown. Both of them appear correct and I don't think this behaviour is a problem.

from idna.

joernheissler avatar joernheissler commented on September 27, 2024

In that case, everything appears to be in order now. Thank you!

from idna.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.