Skip to content

Commit 1dbd03d

Browse files
736-c41-2c1-e464fc974mjs
authored andcommitted
Fix IMAP4WithTimeout compatibility with Python 3.14
Python 3.14 changed imaplib.IMAP4.file from a plain instance attribute to a read-only property (see cpython commit introducing the change). The open() override in IMAP4WithTimeout assigned to self.file directly, which now raises: AttributeError: property 'file' of 'IMAP4WithTimeout' object has no setter The fix mirrors what was already done for IMAP4_TLS in commit 64250b0: remove the open() override entirely and instead pass the timeout through to the parent __init__, which calls open() itself using self._file internally. The _create_socket override is kept as-is so the stored self._timeout fallback still applies for any call path that omits an explicit timeout. Fixes #638
1 parent 248f09a commit 1dbd03d

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

imapclient/imap4.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,7 @@
1010
class IMAP4WithTimeout(imaplib.IMAP4):
1111
def __init__(self, address: str, port: int, timeout: Optional[float]) -> None:
1212
self._timeout = timeout
13-
imaplib.IMAP4.__init__(self, address, port)
14-
15-
def open(
16-
self, host: str = "", port: int = 143, timeout: Optional[float] = None
17-
) -> None:
18-
# This is overridden to make it consistent across Python versions.
19-
self.host = host
20-
self.port = port
21-
self.sock = self._create_socket(timeout)
22-
self.file = self.sock.makefile("rb")
13+
super().__init__(address, port, timeout=timeout)
2314

2415
def _create_socket(self, timeout: Optional[float] = None) -> socket.socket:
2516
return socket.create_connection(

0 commit comments

Comments
 (0)