jazzband / imaplib2

Fork of Piers Lauder's imaplib2 library for Python.
https://imaplib2.readthedocs.io/
MIT License
33 stars 29 forks source link

Remove crash if debug is set and port is not set #11

Closed thekix closed 3 years ago

thekix commented 3 years ago

If the debug argument is set, then this block is executed:

 if __debug __:
     if debug:
         self._mesg('connected to %s on port %s' % (self.host, self.port))

The variables self.host and self.port are not set yet, then imaplib2 will crash with a getattr() function error:

  File "/usr/lib/python3/dist-packages/imaplib2.py", line 340, in __init __
    self._mesg('connected to %s on port %s' % (self.host, self.port))
  File "/usr/lib/python3/dist-packages/imaplib2.py", line 404, in __getattr __
    raise AttributeError("Unknown IMAP4 command: '%s'" % attr)

We can solve this problem changing the self.host to host and self.port to port, like this:

 if __debug __:
     if debug:
         self._mesg('connected to %s on port %s' % (host, port))

Then the problem is solved.

Closes #10