[Patches] [ python-Patches-469910 ] Bugfix for imaplib for macintosh
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 11 Oct 2001 12:14:12 -0700
Patches item #469910, was opened at 2001-10-10 08:29
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=469910&group_id=5470
Category: Library (Lib)
Group: 2.0.1 bugfix
Status: Open
Resolution: None
Priority: 5
Submitted By: Alfonso Baciero (alczj)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bugfix for imaplib for macintosh
Initial Comment:
When you try to connect to a imap server with a
macintosh, you get an error:
>>>
>>> import imaplib
>>> M = imaplib.IMAP4('imapserver')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "Macintosh HD:Applications (Mac OS
9):Python 2.1.1:Lib:imaplib.py", line 168, in __init__
self._simple_command(cap)
File "Macintosh HD:Applications (Mac OS
9):Python 2.1.1:Lib:imaplib.py", line 844, in
_simple_command
return self._command_complete(name,
apply(self._command, (name,) + args))
File "Macintosh HD:Applications (Mac OS
9):Python 2.1.1:Lib:imaplib.py", line 676, in
_command_complete
raise self.abort('command: %s => %s' % (name,
val))
* CAPABILITY IMAP4 IMAP4REV1 NAMESPACE
IDLE SCAN SORT MAILBOX-REFERRALS
LOGIN-REFERRALS AUTH=LOGIN
THREAD=ORDEREDSUBJEC'
>>>
That is because the file associated to the socket
created by IMAP4 object is not binary, and that is a
problem with end lines in macintosh.
When I changed the file mode to binary it works:
------- start patch-----------------------
*** imaplib.py Wed Oct 10 17:12:37 2001
--- imaplib-old.py Wed Oct 10 17:12:03 2001
***************
*** 207,213 ****
"""
self.sock = socket.socket(socket.AF_INET,
socket.SOCK_STREAM)
self.sock.connect((self.host, self.port))
! self.file = self.sock.makefile('rb')
def read(self, size):
--- 207,213 ----
"""
self.sock = socket.socket(socket.AF_INET,
socket.SOCK_STREAM)
self.sock.connect((self.host, self.port))
! self.file = self.sock.makefile('r')
def read(self, size):
--------end of patch -----------
With linux, the new imaplib works too, but I have
not tested it in other platforms,
Alfonso Baciero.
----------------------------------------------------------------------
>Comment By: Martin v. Löwis (loewis)
Date: 2001-10-11 12:14
Message:
Logged In: YES
user_id=21627
The patch looks fine to me.
In a binary stream (such as an LDAP connection), using
readline (i.e. C fgets) seems risky, since end-of-line
characters are really only meaningful in text mode. However,
it appears that it should still work on any implementation
where \n indicates ASCII LF in binary mode (i.e. on any
implementation that uses ASCII, which is a prerequisite in
Python, anyway).
If somebody thinks this is a problem, IMAP4.readline needs
to be rewritten to look for the line delimiter CRLF itself.
BTW, how did you issue the "canned response"?
----------------------------------------------------------------------
Comment By: Alfonso Baciero (alczj)
Date: 2001-10-10 10:05
Message:
Logged In: YES
user_id=346109
There's no uploaded file! You have to check the
checkbox labeled "Check to Upload & Attach File"
when you upload a file.
Please try again.
(This is a SourceForge annoyance that we can do
nothing about. :-( )
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=469910&group_id=5470