[Patches] [ python-Patches-469910 ] Bugfix for imaplib for macintosh
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 15 Oct 2001 09:12:41 -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: Closed
Resolution: Accepted
Priority: 5
Submitted By: Alfonso Baciero (alczj)
Assigned to: Guido van Rossum (gvanrossum)
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: Alfonso Baciero (alczj)
Date: 2001-10-15 09:12
Message:
Logged In: YES
user_id=346109
In addition to the canned response menu, I see other
menus in this patch tracker: "assigned to", "status" and
so on. And I am not admin in any project: in fact, I
opened the SF account to submit this bug!
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2001-10-15 06:46
Message:
Logged In: YES
user_id=6380
I think using readline on a binary-opened file is fine, so
I've applied this now.
I gues he saw the canned response menu because he's an admin
for another SF project. I've seen weirdnesses like this
before (some submitters can close their own bug report, very
confusing).
----------------------------------------------------------------------
Comment By: Alfonso Baciero (alczj)
Date: 2001-10-15 03:04
Message:
Logged In: YES
user_id=346109
I don't think I have to say any more about the patch.
About the canned response issue, when I posted the
patch, I didn´t upload the patch as file. Later I uploaded
the patch file and I think that I put the canned response
menu to Missing Upload (I now realize that I had not to
do that).
Sorry by the delay in my response but I haven't been
able to connect to internet before.
----------------------------------------------------------------------
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