New submission from Pablo Oliveira pa...@sifflez.org:
I'm using Python 2.7.3rc2 from debian sid packages.
If a mailbox.Maildir object is created with a unicode dirname,
retrieving a message tagged with maildir flags with get() or get_message()
fails with the following exception:
Traceback (most recent call last):
File reproduce.py, line 21, in module
mb.get_message(key)
File /usr/lib/python2.7/mailbox.py, line 343, in get_message
msg.set_info(name.split(self.colon)[-1])
File /usr/lib/python2.7/mailbox.py, line 1480, in set_info
raise TypeError('info must be a string: %s' % type(info))
TypeError: info must be a string: type 'unicode'
Since python os.path module seems to cope with unicode paths
http://docs.python.org/howto/unicode.html, it would be nice to fix this issue.
Attached is a simple script reproducing the bug.
The following patch seems to solve the issue for me:
--- /usr/lib/python2.7/mailbox.py 2012-04-23 01:25:48.0 +0200
+++ mailbox.py 2012-05-26 00:34:03.585347627 +0200
@@ -1474,7 +1474,7 @@
def set_info(self, info):
Set the message's info string.
-if isinstance(info, str):
+if isinstance(info, basestring):
self._info = info
else:
raise TypeError('info must be a string: %s' % type(info))
Regards,
Pablo Oliveira.
--
components: Library (Lib)
files: reproduce.py
messages: 161629
nosy: poliveira
priority: normal
severity: normal
status: open
title: mailbox.Maildir.get_message() may fail when Maildir dirname is a unicode
string
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file25710/reproduce.py
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14922
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com