classification
Title: mailcap module may not work on non-POSIX platforms if MAILCAPS env variable is set
Type: behavior Stage: resolved
Components: Library (Lib), Windows Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: 6484 Superseder:
Assigned To: ncoghlan Nosy List: eric.araujo, gnofi, ncoghlan, ned.deily, python-dev
Priority: normal Keywords:

Created on 2010-09-23 03:03 by gnofi, last changed 2011-08-27 14:32 by ncoghlan. This issue is now closed.

Files
File name Uploaded Description Edit
mailcap_trunk.py gnofi, 2010-09-23 03:03 trunk patch
mailcap_py3k.py gnofi, 2010-09-23 03:04 py3k branch patch
Messages (10)
msg117163 - (view) Author: Gregory Nofi (gnofi) Date: 2010-09-23 03:03
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).
msg117164 - (view) Author: Gregory Nofi (gnofi) Date: 2010-09-23 03:06
Fixing typo in title
msg117326 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2010-09-24 19:15
Thanks for the patches.  Can you also add a test case to Lib/test/mailcap.py to cover this problem?
msg117395 - (view) Author: Gregory Nofi (gnofi) Date: 2010-09-25 22:38
I'm also creating a test for mailcap (Issue 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.
msg117939 - (view) Author: Gregory Nofi (gnofi) Date: 2010-10-04 01:44
I just submitted new versions of test_mailcap.py in case 6484.
msg135470 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-05-07 15:29
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).
msg135557 - (view) Author: Gregory Nofi (gnofi) Date: 2011-05-09 02:24
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.
msg135593 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-05-09 14:40
Okay.  Nonetheless, splitting on os.sep doesn’t cost us anything and is IMO a good practice to follow.
msg143067 - (view) Author: Roundup Robot (python-dev) Date: 2011-08-27 14:17
New changeset 7b83d2c1aad9 by Nick Coghlan in branch 'default':
Fix #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
msg143069 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-08-27 14:32
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.
History
Date User Action Args
2011-08-27 14:32:06ncoghlansetstatus: open -> closed
versions: - Python 2.7, Python 3.2
messages: + msg143069

resolution: fixed
stage: patch review -> resolved
2011-08-27 14:17:44python-devsetnosy: + python-dev
messages: + msg143067
2011-08-23 14:02:27ncoghlansetstage: test needed -> patch review
versions: + Python 3.2, Python 3.3, - Python 3.1
2011-08-23 14:01:41ncoghlansetassignee: ncoghlan

nosy: + ncoghlan
2011-05-09 14:40:37eric.araujosetmessages: + msg135593
2011-05-09 02:24:29gnofisetmessages: + msg135557
2011-05-07 15:29:10eric.araujosetnosy: + eric.araujo
messages: + msg135470
2011-05-07 15:27:49eric.araujosetdependencies: + No unit test for mailcap module
2010-10-04 01:44:58gnofisetmessages: + msg117939
2010-09-25 22:38:37gnofisetmessages: + msg117395
2010-09-24 19:15:28ned.deilysetnosy: + ned.deily

messages: + msg117326
stage: test needed
2010-09-24 15:05:27ronaldoussorensetassignee: ronaldoussoren -> (no value)

components: - Macintosh
nosy: - ronaldoussoren
2010-09-23 03:06:20gnofisetmessages: + msg117164
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
2010-09-23 03:04:32gnofisetfiles: + mailcap_py3k.py
2010-09-23 03:03:55gnoficreate