Skip to content
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

Closed
petrosr2 mannequin opened this issue May 9, 2015 · 6 comments
Closed

test_mailcap fails if a mailcap file contains a non-decodable character #68340

petrosr2 mannequin opened this issue May 9, 2015 · 6 comments
Labels
stdlib Python modules in the Lib dir

Comments

@petrosr2
Copy link
Mannequin

petrosr2 mannequin commented May 9, 2015

BPO 24152
Nosy @ned-deily
Files
  • results
  • 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:

    assignee = None
    closed_at = None
    created_at = <Date 2015-05-09.20:45:44.388>
    labels = ['library']
    title = 'test_mailcap fails if a mailcap file contains a non-decodable character'
    updated_at = <Date 2015-05-09.21:42:06.442>
    user = 'https://bugs.python.org/petrosr2'

    bugs.python.org fields:

    activity = <Date 2015-05-09.21:42:06.442>
    actor = 'ned.deily'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2015-05-09.20:45:44.388>
    creator = 'petrosr2'
    dependencies = []
    files = ['39330']
    hgrepos = ['308']
    issue_num = 24152
    keywords = []
    message_count = 3.0
    messages = ['242840', '242842', '242843']
    nosy_count = 2.0
    nosy_names = ['ned.deily', 'petrosr2']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue24152'
    versions = ['Python 3.4', 'Python 3.5']

    @petrosr2
    Copy link
    Mannequin Author

    petrosr2 mannequin commented May 9, 2015

    UnicodeDecodeError

    @petrosr2 petrosr2 mannequin added type-crash A hard crash of the interpreter, possibly with a core dump tests Tests in the Lib/test dir labels May 9, 2015
    @petrosr2
    Copy link
    Mannequin Author

    petrosr2 mannequin commented May 9, 2015

    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:
    test_mailcap

    @ned-deily
    Copy link
    Member

    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.

    @ned-deily ned-deily added stdlib Python modules in the Lib dir and removed tests Tests in the Lib/test dir labels May 9, 2015
    @ned-deily ned-deily changed the title test_mailcap fails test_mailcap fails if a mailcap file contains a non-decodable character May 9, 2015
    @ned-deily ned-deily removed the type-crash A hard crash of the interpreter, possibly with a core dump label May 9, 2015
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @hugovk
    Copy link
    Member

    hugovk commented Apr 26, 2022

    Note that mailcap will be deprecated in Python 3.11 and removed in 3.13:

    @AA-Turner
    Copy link
    Member

    Closing per Hugo's comment.

    A

    @hugovk
    Copy link
    Member

    hugovk commented May 9, 2023

    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

    @hugovk hugovk closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2023
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants