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

mailcap module may not work on non-POSIX platforms if MAILCAPS env variable is set #54132

Closed
gnofi mannequin opened this issue Sep 23, 2010 · 10 comments
Closed

mailcap module may not work on non-POSIX platforms if MAILCAPS env variable is set #54132

gnofi mannequin opened this issue Sep 23, 2010 · 10 comments
Assignees
Labels
OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@gnofi
Copy link
Mannequin

gnofi mannequin commented Sep 23, 2010

BPO 9923
Nosy @ncoghlan, @ned-deily, @merwok
Dependencies
  • bpo-6484: No unit test for mailcap module
  • Files
  • mailcap_trunk.py: trunk patch
  • mailcap_py3k.py: py3k branch patch
  • 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 = 'https://github.com/ncoghlan'
    closed_at = <Date 2011-08-27.14:32:06.701>
    created_at = <Date 2010-09-23.03:03:55.277>
    labels = ['type-bug', 'library', 'OS-windows']
    title = 'mailcap module may not work on non-POSIX platforms if MAILCAPS env variable is set'
    updated_at = <Date 2011-08-27.14:32:06.700>
    user = 'https://bugs.python.org/gnofi'

    bugs.python.org fields:

    activity = <Date 2011-08-27.14:32:06.700>
    actor = 'ncoghlan'
    assignee = 'ncoghlan'
    closed = True
    closed_date = <Date 2011-08-27.14:32:06.701>
    closer = 'ncoghlan'
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2010-09-23.03:03:55.277>
    creator = 'gnofi'
    dependencies = ['6484']
    files = ['18969', '18970']
    hgrepos = []
    issue_num = 9923
    keywords = []
    message_count = 10.0
    messages = ['117163', '117164', '117326', '117395', '117939', '135470', '135557', '135593', '143067', '143069']
    nosy_count = 5.0
    nosy_names = ['ncoghlan', 'ned.deily', 'eric.araujo', 'gnofi', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9923'
    versions = ['Python 3.3']

    @gnofi
    Copy link
    Mannequin Author

    gnofi mannequin commented Sep 23, 2010

    mailcap.getcaps() has a call to mailcap.listmailcapfiles(), which returns a list of all mailcap files found on the system.

    listmailcapfiles() first looks for the MAILCAPS environment variable. If it exists, it converts the string value into a list by splitting it on ":". This will not work on platforms that use other path separators, like Windows (";").

    Attached are patches that use os.pathsep instead.

    For more information about the MAILCAPS variable, see Appendix A in RFC 1524 (http://tools.ietf.org/html/rfc1524.html).

    @gnofi gnofi mannequin assigned ronaldoussoren Sep 23, 2010
    @gnofi gnofi mannequin added OS-mac stdlib Python modules in the Lib dir OS-windows type-bug An unexpected behavior, bug, or error labels Sep 23, 2010
    @gnofi
    Copy link
    Mannequin Author

    gnofi mannequin commented Sep 23, 2010

    Fixing typo in title

    @gnofi gnofi mannequin changed the title mailcap module may will not work on non-POSIX platforms if MAILCAPS env variable is set mailcap module may not work on non-POSIX platforms if MAILCAPS env variable is set Sep 23, 2010
    @ronaldoussoren ronaldoussoren removed their assignment Sep 24, 2010
    @ned-deily
    Copy link
    Member

    Thanks for the patches. Can you also add a test case to Lib/test/mailcap.py to cover this problem?

    @gnofi
    Copy link
    Mannequin Author

    gnofi mannequin commented Sep 25, 2010

    I'm also creating a test for mailcap (bpo-6484), which is how I found this bug. I'll have an update to that test submitted soon once I implement r.david.murray's helpful suggestions.

    @gnofi
    Copy link
    Mannequin Author

    gnofi mannequin commented Oct 4, 2010

    I just submitted new versions of test_mailcap.py in case 6484.

    @merwok
    Copy link
    Member

    merwok commented May 7, 2011

    BTW, is there a real use case that lead you to open this report, or is it just theoretical? I’m not even sure mailcap is used on non-UNIX (and even there, I think it’s not used by recent tools).

    @gnofi
    Copy link
    Mannequin Author

    gnofi mannequin commented May 9, 2011

    It's just theoretical. A web search shows that a few Windows programs, like PC Pine, can use $MAILCAPS. But none of those tools look recent, like you said.

    @merwok
    Copy link
    Member

    merwok commented May 9, 2011

    Okay. Nonetheless, splitting on os.sep doesn’t cost us anything and is IMO a good practice to follow.

    @ncoghlan ncoghlan self-assigned this Aug 23, 2011
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 27, 2011

    New changeset 7b83d2c1aad9 by Nick Coghlan in branch 'default':
    Fix bpo-9923: mailcap now uses the OS path separator for the MAILCAP envvar. Not backported, since it could break cases where people worked around the old POSIX-specific behaviour on non-POSIX platforms.
    http://hg.python.org/cpython/rev/7b83d2c1aad9

    @ncoghlan
    Copy link
    Contributor

    As noted in the commit message, I didn't backport this, since it didn't seem worth risking breaking even the unlikely case that someone actually *was* using the MAILCAP environment variable on Windows.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants