-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
test_mailcap fails if a mailcap file contains a non-decodable character #68340
Comments
UnicodeDecodeError |
running command over PuTTY on Ubuntu 3.13, python 2.7.6 $ ./python -m test test_mailcap [1/1] test_mailcap
test test_mailcap failed -- Traceback (most recent call last):
File "/home/petrosr2/Documents/opensource/cpy/Lib/test/test_mailcap.py", line 126, in test_system_mailcap
caps = mailcap.getcaps()
File "/home/petrosr2/Documents/opensource/cpy/Lib/mailcap.py", line 26, in getcaps
morecaps = readmailcapfile(fp)
File "/home/petrosr2/Documents/opensource/cpy/Lib/mailcap.py", line 64, in readmailcapfile
line = fp.readline()
File "/home/petrosr2/Documents/opensource/cpy/Lib/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3820: ordinal not in range(128) 1 test failed: |
I can reproduce the failure by arbitrarily adding a non-ascii character to one of the mailcap files searched for by the mailcap module (https://docs.python.org/3/library/mailcap.html#mailcap.getcaps), like $HOME/.mailcap, and by setting the process to an ascii-only locale (export LANG=C). While this might be a somewhat unusual combination in practice, mailcap should be able to handle it. By the way, this is a Python 3 problem since test_mailcap does not exist in Python 2. 2.7.6 might be the version of the system-supplied Python, but you appeared to be running with a Python you built. Try ./python -V to show the version of the Python you are using. |
Note that mailcap will be deprecated in Python 3.11 and removed in 3.13: |
Closing per Hugo's comment. A |
Actually closing per my comment :) Plus 3.12 is now closed to new features, and realistically this won't be fixed in the next two weeks. https://discuss.python.org/t/postponing-3-12-beta-1-feature-freeze/26406/11?u=hugovk |
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: