New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
codecs.lookup can raise exceptions other than LookupError #40295
Comments
codecs.lookup raises ValueError when given an empty For example:
Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC
v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> import codecs
>>> codecs.lookup('')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "c:\python23\lib\encodings\__init__.py", line 84, in
search_function
globals(), locals(), _import_tail)
ValueError: Empty module name
>>> codecs.lookup(u'\uabcd')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
UnicodeEncodeError: 'ascii' codec can't encode
character u'\uabcd' in position 0: ordinal not in range
(128)
>>> |
Logged In: YES What exactly are you complaining about? I'd expect codecs.lookup I believe it's documented somewhere that encoding names must |
Logged In: YES The other exceptions occur when strings or unicode objects My use case is to see if an user supplied unicode string is a |
Logged In: YES This much seems to be fixed in CVS, actually :-) |
Logged In: YES Yes, it does look like lookup('') is fixed in CVS. So the I'm willing to put together a patch to raise LookupError if |
Logged In: YES Well, *I* don't think that's a particularly good idea. I don't know if |
Logged In: YES I don't think we should change anything. First of all, the lookup function interfaces to a codec Second, the name you enter as argument usually maps to a Closing this request. |
Logged In: YES Okay, that works for me. We might want to update the Thanks for the quick response :). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: