[Patches] [ python-Patches-469910 ] Bugfix for imaplib for macintosh

noreply@sourceforge.net noreply@sourceforge.net
Wed, 10 Oct 2001 08:29:40 -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.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=469910&group_id=5470